Permalink
Browse files

Don't duplicate RUBYOPT if it has already been set somehow

  • Loading branch information...
1 parent 2708880 commit 589ec4e3dae05936bf44003ee9757c7380ff32d0 @indirect indirect committed Apr 7, 2010
Showing with 22 additions and 3 deletions.
  1. +5 −3 lib/bundler/cli.rb
  2. +13 −0 spec/other/exec_spec.rb
  3. +4 −0 spec/support/path.rb
View
@@ -163,9 +163,11 @@ def exec(*)
# Set RUBYOPT
rubyopt = [ENV["RUBYOPT"]].compact
- rubyopt.unshift "-rbundler/setup"
- rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
- ENV["RUBYOPT"] = rubyopt.join(' ')
+ if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
+ rubyopt.unshift "-rbundler/setup"
+ rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
+ ENV["RUBYOPT"] = rubyopt.join(' ')
+ end
begin
# Run
View
@@ -78,6 +78,19 @@
should_not_be_installed "rack_middleware 1.0"
end
+ it "should not duplicate already exec'ed RUBYOPT or PATH" do
+ install_gemfile <<-G
+ gem "rack"
+ G
+ rubyopt = "-I#{bundler_path} -rbundler/setup"
+
+ bundle "exec 'echo $RUBYOPT'"
+ out.should == rubyopt
+
+ bundle "exec 'echo $RUBYOPT'", :env => {"RUBYOPT" => rubyopt}
+ out.should == rubyopt
+ end
+
describe "when locked" do
it "uses .bundle/environment.rb" do
gemfile <<-G
View
@@ -50,6 +50,10 @@ def lib_path(*args)
tmp("libs", *args)
end
+ def bundler_path
+ Pathname.new(File.expand_path('../../../lib', __FILE__))
+ end
+
extend self
end
end

0 comments on commit 589ec4e

Please sign in to comment.