diff options
author | Colby Swandale <me@colby.fyi> | 2018-09-05 23:19:17 +1000 |
---|---|---|
committer | Colby Swandale <me@colby.fyi> | 2018-09-13 22:05:34 +1000 |
commit | 0676955f6d951e3af70e4efecbe6ef8fa8397d75 (patch) | |
tree | 63ae4a6780fb4b05501ddffe8a834f5c706463f4 | |
parent | 4e215b74197581de3b11cf3e2948d604da7ca2d6 (diff) | |
download | bundler-colby/fix-bundler-load-error.tar.gz |
Fix loadError occuring in https://github.com/bundler/bundler/issues/6537colby/fix-bundler-load-error
-rw-r--r-- | lib/bundler/shared_helpers.rb | 7 | ||||
-rw-r--r-- | spec/bundler/shared_helpers_spec.rb | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 7ff391ab60..dca17885dd 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -300,7 +300,12 @@ module Bundler def set_bundle_variables begin - Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", Bundler.rubygems.bin_path("bundler", "bundle", VERSION) + exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) + unless File.exist?(exe_file) + exe_file = File.expand_path("../../../exe/bundle", __FILE__) + end + + Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file rescue Gem::GemNotFoundException Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", File.expand_path("../../../exe/bundle", __FILE__) end diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb index b8f099d5ba..72b1c2a51f 100644 --- a/spec/bundler/shared_helpers_spec.rb +++ b/spec/bundler/shared_helpers_spec.rb @@ -378,6 +378,16 @@ RSpec.describe Bundler::SharedHelpers do it_behaves_like "ENV['RUBYLIB'] gets set correctly" end + context "bundle executable in ENV['BUNDLE_BIN_PATH'] does not exist" do + before { ENV["BUNDLE_BIN_PATH"] = "/does/not/exist" } + before { Bundler.rubygems.replace_bin_path [], [] } + + it "sets BUNDLE_BIN_PATH to the bundle executable file" do + subject.set_bundle_environment + expect(ENV["BUNDLE_BIN_PATH"]).to eq(File.expand_path("../../../exe/bundle", __FILE__)) + end + end + context "ENV['RUBYLIB'] already contains the bundler's ruby version lib path" do let(:ruby_lib_path) { "stubbed_ruby_lib_dir" } |