[rubygems/rubygems] Fix restarting with locked version when $PROGRAM_NAME has been changed
Use Process.argv0 instead of $PROGRAM_NAME because $PROGRAM_NAME is liable to be changed but Process.argv0 is not. https://github.com/rubygems/rubygems/commit/43b747dc9e
This commit is contained in:
parent
3cb79d4082
commit
6cde41bc52
@ -84,8 +84,8 @@ module Bundler
|
||||
require "shellwords"
|
||||
cmd = [*Shellwords.shellsplit(bundler_spec_original_cmd), *ARGV]
|
||||
else
|
||||
cmd = [$PROGRAM_NAME, *ARGV]
|
||||
cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
|
||||
cmd = [Process.argv0, *ARGV]
|
||||
cmd.unshift(Gem.ruby) unless File.executable?(Process.argv0)
|
||||
end
|
||||
|
||||
Bundler.with_original_env do
|
||||
|
@ -194,6 +194,25 @@ RSpec.describe "Self management" do
|
||||
expect(out).to include("Using bundler #{Bundler::VERSION}")
|
||||
end
|
||||
|
||||
it "uses the right original script when re-execing, even if `$0` has been changed", :ruby_repo do
|
||||
bundle "config path vendor/bundle"
|
||||
|
||||
system_gems "bundler-9.9.9", path: vendored_gems
|
||||
|
||||
test = bundled_app("test.rb")
|
||||
|
||||
create_file test, <<~RUBY
|
||||
$0 = "this is the program name"
|
||||
require "bundler/setup"
|
||||
RUBY
|
||||
|
||||
lockfile_bundled_with("9.9.9")
|
||||
|
||||
sys_exec "#{Gem.ruby} #{test}", artifice: nil, raise_on_error: false
|
||||
expect(err).to include("Could not find myrack-1.0.0")
|
||||
expect(err).not_to include("this is the program name")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def lockfile_bundled_with(version)
|
||||
|
Loading…
x
Reference in New Issue
Block a user