diff options
author | chrismo <chrismo@clabs.org> | 2016-06-22 16:36:21 -0500 |
---|---|---|
committer | chrismo <chrismo@clabs.org> | 2016-06-22 23:34:20 -0500 |
commit | 9a8ab67da6567c767307e8861893761542483ba0 (patch) | |
tree | 086ca9f6589666251ffbc1d0a71d0bf7caa5f28b /spec/bundler | |
parent | a65a2db118ed714586ac4c56a0584c97bf0305df (diff) | |
download | bundler-9a8ab67da6567c767307e8861893761542483ba0.tar.gz |
Unset `GEM_PATH` with `nil` not empty string.
This should fix #4592, the tests all pass, but the line of code in
question goes back to 2010, so this sorta seems slightly dangerous, but
it's probable the circumstances of hitting this line in conjunction with
`bundle exec` is a combination that didn't exist prior to 1.12.x.
Issue #4592 has a full diagnosis, but the gist of it is this: if an
empty string is passed as the `GEM_PATH` to the subsequent process
launched by `bundle exec`, then if the `cmd` portion of `bundle exec` is
a ruby shebanged file, then if the current bundle install uses a local
path (`disable_shared_gems` is true) then it won't be able to find the
bundler gem at all because Bundler doesn't install itself into its own
Bundle, it's only installed in the system gems for the Ruby.
`nil` must be passed because the RubyGems code that sets up the
`GEM_PATH` does a conditional on the current `GEM_PATH` and empty string
evaluates to true, whereas `nil` evaluates to false. In the false case
the `GEM_PATH` is internally populated with the system gems path such
that the bundler gem can be found.
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/bundler_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb index 2ad3704d..f338b526 100644 --- a/spec/bundler/bundler_spec.rb +++ b/spec/bundler/bundler_spec.rb @@ -140,4 +140,16 @@ describe Bundler do it_behaves_like "it returns the correct executable" end end + + describe "configuration" do + context "disable_shared_gems" do + it "should unset GEM_PATH with nil" do + env = {} + settings = { :disable_shared_gems => true } + Bundler.send(:configure_gem_path, env, settings) + expect(env.keys).to include("GEM_PATH") + expect(env["GEM_PATH"]).to be_nil + end + end + end end |