diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-02-01 17:29:32 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-02-01 17:29:32 -0600 |
commit | 5b639c3d774e4a83f1a15ec15e16b3e777c79642 (patch) | |
tree | 1bb9829e4c5b330c2ae3b83580367dcb1d0570eb | |
parent | 789dabcb48adf58175a75751c4aaf08e4c39e707 (diff) | |
download | bundler-5b639c3d774e4a83f1a15ec15e16b3e777c79642.tar.gz |
[Exec] Avoid loading the definition before exec-ing
-rw-r--r-- | lib/bundler/cli/exec.rb | 12 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 15 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 12 |
3 files changed, 16 insertions, 23 deletions
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 4ccc4ba55a..77e75580f5 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -21,18 +21,12 @@ module Bundler ui = Bundler.ui raise ArgumentError if cmd.nil? - # First, try to exec directly to something in PATH SharedHelpers.set_bundle_environment bin_path = Bundler.which(@cmd) - if bin_path - Bundler.ui = nil - Kernel.exec([bin_path, @cmd], *args) - end - - # If that didn't work, set up the whole bundle - Bundler.definition.validate_ruby! - Bundler.load.setup_environment Bundler.ui = nil + # First, try to exec directly to something in PATH + Kernel.exec([bin_path, @cmd], *args) if bin_path + # Just exec using the given command Kernel.exec(@cmd, *args) rescue Errno::EACCES, Errno::ENOEXEC Bundler.ui = ui diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 6ef476b9dc..c2d5ad4b0a 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -13,7 +13,7 @@ module Bundler specs = groups.any? ? @definition.specs_for(groups) : requested_specs - setup_environment + SharedHelpers.set_bundle_environment Bundler.rubygems.replace_entrypoints(specs) # Activate the specs @@ -205,19 +205,6 @@ module Bundler output end - def setup_environment - begin - ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) - rescue Gem::GemNotFoundException - ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../exe/bundle", __FILE__) - end - - # Set BUNDLE_GEMFILE - ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s - - SharedHelpers.set_bundle_environment - end - private def prune_gem_cache(resolve, cache_path) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index ca26f7b4bf..654359d1ed 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -75,6 +75,7 @@ module Bundler end def set_bundle_environment + set_bundle_variables set_path set_rubyopt set_rubylib @@ -155,6 +156,17 @@ module Bundler end end + def set_bundle_variables + begin + ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) + rescue Gem::GemNotFoundException + ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../exe/bundle", __FILE__) + end + + # Set BUNDLE_GEMFILE + ENV["BUNDLE_GEMFILE"] = find_gemfile.to_s + end + def set_path paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR) paths.unshift "#{Bundler.bundle_path}/bin" |