From a45ed77a067f0fbef8d073281d8a6f2f5644b746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 25 Sep 2018 16:31:25 -0300 Subject: Resolve gemfile from config in the general case For example, when using `bundler` via `-rbundler/setup`. --- lib/bundler/shared_helpers.rb | 3 ++- spec/commands/config_spec.rb | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 529379ba44..e8f9bfd610 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -237,7 +237,8 @@ module Bundler end def find_gemfile - given = ENV["BUNDLE_GEMFILE"] + require_relative "../bundler" + given = Bundler.settings[:gemfile] return given if given && !given.empty? find_file(*gemfile_names) end diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb index e58a266212..11fdd1ac78 100644 --- a/spec/commands/config_spec.rb +++ b/spec/commands/config_spec.rb @@ -518,17 +518,33 @@ end RSpec.describe "setting gemfile via config" do context "when only the non-default Gemfile exists" do - it "persists the gemfile location to .bundle/config" do + before do gemfile bundled_app("NotGemfile"), <<-G source "#{file_uri_for(gem_repo1)}" gem 'rack' G bundle "config set --local gemfile #{bundled_app("NotGemfile")}" + end + + it "persists the gemfile location to .bundle/config" do expect(File.exist?(bundled_app(".bundle/config"))).to eq(true) bundle "config list" expect(out).to include("NotGemfile") end + + it "gets used when requiring bundler/setup" do + bundle :install + code = "puts $LOAD_PATH.count {|path| path =~ /rack/} == 1" + + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + G + + ruby! code, :env => { "RUBYOPT" => "-r#{lib_dir}/bundler/setup" }, :no_lib => true + + expect(out).to eq("true") + end end end -- cgit v1.2.1