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

Commit

Permalink
Fix loadError occuring in #6537
Browse files Browse the repository at this point in the history
  • Loading branch information
colby-swandale committed Sep 6, 2018
1 parent 4e215b7 commit 9c1a26a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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
11 changes: 11 additions & 0 deletions spec/bundler/shared_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,17 @@
it_behaves_like "ENV['RUBYLIB'] gets set correctly"
end

context "bundle exec in ENV['BUNDLE_BIN_PATH'] does not exist" do
before do
ENV["BUNDLE_BIN_PATH"] = "/does/not/exist"
end

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

0 comments on commit 9c1a26a

Please sign in to comment.