diff options
author | Andre Arko <andre@arko.net> | 2015-09-08 13:57:26 -0700 |
---|---|---|
committer | Agis Anastasopoulos <agis.anast@gmail.com> | 2015-09-19 22:17:48 +0300 |
commit | 42b507218fd910feb2a9756bc08dc41181a9d1c4 (patch) | |
tree | 6da2b899d2512eb34d9f53a8141a56b823b4aa98 | |
parent | f5c6978b61826187cecb5ed66a2c21134bc5610b (diff) | |
download | bundler-42b507218fd910feb2a9756bc08dc41181a9d1c4.tar.gz |
Clean RUBYLIB as well in `with_clean_env`
refs #3982
-rw-r--r-- | lib/bundler.rb | 11 | ||||
-rw-r--r-- | spec/runtime/with_clean_env_spec.rb | 6 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 28d488dc18..3d56adec2b 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -275,10 +275,17 @@ module Bundler with_original_env do ENV["MANPATH"] = ENV["BUNDLE_ORIG_MANPATH"] ENV.delete_if {|k, _| k[0, 7] == "BUNDLE_" } - if ENV.key? "RUBYOPT" + + if ENV.key?("RUBYOPT") ENV["RUBYOPT"] = ENV["RUBYOPT"].sub "-rbundler/setup", "" - ENV["RUBYOPT"] = ENV["RUBYOPT"].sub "-I#{File.expand_path("..", __FILE__)}", "" end + + if ENV.key?("RUBYLIB") + rubylib = ENV["RUBYLIB"].split(File::PATH_SEPARATOR) + rubylib.delete(File.expand_path("..", __FILE__)) + ENV["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR) + end + yield end end diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb index e47e32c2cb..eed024a398 100644 --- a/spec/runtime/with_clean_env_spec.rb +++ b/spec/runtime/with_clean_env_spec.rb @@ -42,15 +42,13 @@ describe "Bundler.with_env helpers" do end it "should not pass RUBYOPT changes" do - lib_path = File.expand_path("../../../lib", __FILE__) - Bundler::ORIGINAL_ENV["RUBYOPT"] = " -I#{lib_path} -rbundler/setup" + Bundler::ORIGINAL_ENV["RUBYOPT"] = " -rbundler/setup" Bundler.with_clean_env do expect(`echo $RUBYOPT`.strip).not_to include "-rbundler/setup" - expect(`echo $RUBYOPT`.strip).not_to include "-I#{lib_path}" end - expect(Bundler::ORIGINAL_ENV["RUBYOPT"]).to eq(" -I#{lib_path} -rbundler/setup") + expect(Bundler::ORIGINAL_ENV["RUBYOPT"]).to eq(" -rbundler/setup") end it "cleans RUBYLIB" do |