Permalink
Browse files

Use locked env.rb in `bundle exec` if it is available. Closes issue #177

.
  • Loading branch information...
1 parent d0037c0 commit 59402023bc69181a4e18f0a1a08665b5964bd1ee @rsutphin rsutphin committed with indirect Mar 4, 2010
Showing with 19 additions and 2 deletions.
  1. +7 −2 lib/bundler/cli.rb
  2. +12 −0 spec/other/exec_spec.rb
View
9 lib/bundler/cli.rb
@@ -133,9 +133,14 @@ def exec(*)
ENV['BUNDLE_GEMFILE'] = Bundler::SharedHelpers.default_gemfile.to_s
# Set RUBYOPT
+ locked_env = Bundler.root.join(".bundle/environment.rb")
rubyopt = [ENV["RUBYOPT"]].compact
- rubyopt.unshift "-rbundler/setup"
- rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
+ if locked_env.exist?
+ rubyopt.unshift "-r#{locked_env.to_s}"
+ else
+ rubyopt.unshift "-rbundler/setup"
+ rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
+ end
ENV["RUBYOPT"] = rubyopt.join(' ')
# Run
View
12 spec/other/exec_spec.rb
@@ -77,4 +77,16 @@
out.should == "0.9.1"
should_not_be_installed "rack_middleware 1.0"
end
+
+ it "uses .bundle/environment.rb when locked" do
+ gemfile <<-G
+ gem "rack"
+ G
+
+ bundle "lock"
+ File.open(".bundle/environment.rb", 'a') { |f| f.puts "puts 'using environment.rb'" }
+
+ bundle "exec rackup"
+ out.should == "using environment.rb\n1.0.0"
+ end
end

1 comment on commit 5940202

@matthewtodd

Three cheers for @rsutphin -- thank you!

Please sign in to comment.