summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2015-09-20 09:27:53 +0900
committerHomu <homu@barosl.com>2015-09-20 09:27:53 +0900
commita136afe15df46acc5445395a98f991dbd8641304 (patch)
tree6da2b899d2512eb34d9f53a8141a56b823b4aa98
parent298dee7185c69f33336d9c28a9e8a330b46ac8eb (diff)
parent42b507218fd910feb2a9756bc08dc41181a9d1c4 (diff)
downloadbundler-a136afe15df46acc5445395a98f991dbd8641304.tar.gz
Auto merge of #4002 - agis-:3982-clean-rubylib, r=indirect
Clean RUBYLIB as well in `with_clean_env` Fixes #3982.
-rw-r--r--lib/bundler.rb11
-rw-r--r--spec/runtime/with_clean_env_spec.rb15
2 files changed, 20 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 13dd629a16..eed024a398 100644
--- a/spec/runtime/with_clean_env_spec.rb
+++ b/spec/runtime/with_clean_env_spec.rb
@@ -42,15 +42,22 @@ 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
+ lib_path = File.expand_path("../../../lib", __FILE__)
+ Bundler::ORIGINAL_ENV["RUBYLIB"] = lib_path
+
+ Bundler.with_clean_env do
+ expect(`echo $RUBYLIB`.strip).not_to include(lib_path)
+ end
end
it "should not change ORIGINAL_ENV" do