diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2018-09-25 16:31:25 -0300 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-03-09 18:25:09 +0100 |
commit | a45ed77a067f0fbef8d073281d8a6f2f5644b746 (patch) | |
tree | ed50abebb594a663cc7a9e54f82a994ca1c79962 | |
parent | e7b9ff14dd3f790b03342e02770f8cf411abc705 (diff) | |
download | bundler-a45ed77a067f0fbef8d073281d8a6f2f5644b746.tar.gz |
Resolve gemfile from config in the general case
For example, when using `bundler` via `-rbundler/setup`.
-rw-r--r-- | lib/bundler/shared_helpers.rb | 3 | ||||
-rw-r--r-- | 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 |