Skip to content
Open
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
2 changes: 1 addition & 1 deletion bundler/lib/bundler/cli/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run
bin_path.delete_suffix!(".bat") if Gem.win_platform?
kernel_load(bin_path, *args)
else
bin_path = "./" + bin_path unless File.absolute_path?(bin_path)
bin_path = "./" + bin_path unless File.absolute_path?(bin_path) || bin_path.start_with?("./", "../")
kernel_exec(bin_path, *args)
end
else
Expand Down
26 changes: 26 additions & 0 deletions spec/commands/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,32 @@
expect(out).to include(rubylib)
end

it "does not duplicate a relative path prefix when exec'ing to a relative path" do
skip "https://github.com/ruby/rubygems/issues/3351" if Gem.win_platform?

create_file("script", "#!/usr/bin/env ruby\nputs $0")

install_gemfile <<-G
source "https://gem.repo1"
G

bundle "exec ./script", env: { "BUNDLE_DISABLE_EXEC_LOAD" => "true" }
expect(out).to eq("./script")
end

it "prepends a relative path prefix when exec'ing to a hidden file in the current directory" do
skip "https://github.com/ruby/rubygems/issues/3351" if Gem.win_platform?

create_file(".script", "#!/usr/bin/env ruby\nputs $0")

install_gemfile <<-G
source "https://gem.repo1"
G

bundle "exec .script", env: { "BUNDLE_DISABLE_EXEC_LOAD" => "true" }
expect(out).to eq("./.script")
end

it "errors nicely when the argument doesn't exist" do
install_gemfile <<-G
source "https://gem.repo1"
Expand Down
Loading