Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Fix loadError occurring in nested bundle exec calls #6689

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ def set_env(key, value)

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
Expand Down
10 changes: 10 additions & 0 deletions spec/bundler/shared_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@
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" }

Expand Down