Fix restarting with locked version when $PROGRAM_NAME has been changed
#8320
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was the end-user or developer problem that led to this PR?
If a ruby process has changed it's name for ease of understanding in
psortopoutput, and then loads bundler, but the correct bundler is not installed, then the error message the user sees is very confusing.Links:
phusion/passenger#2567
phusion/passenger#2577
What is your fix for the problem, implemented in this PR?
Use
Process.argv0instead of$PROGRAM_NAMEbecause$PROGRAM_NAMEis liable to be changed butProcess.argv0is not.Links:
$0/$PROCESS_NAMEmay be reassigned: https://docs.ruby-lang.org/en/3.3/globals_rdoc.html#label-240Process.argv0docs indicating that it is not reassigned with$0/$PROCESS_NAME: https://docs.ruby-lang.org/en/master/Process.html#method-c-argv0Make sure the following tasks are checked
Sorry I didn't write any tests, I have no idea how to setup the required failing environment in your test environment. I've created a minimal reproduction environment below, which I used to verify the fix.
If you create all of these files, then run the following commands, you can trigger the bad error message, and then if you patch the
/usr/local/lib/ruby/site_ruby/3.2.0/bundler/self_manager.rbfile in the container and runruby test.rbagain, you will get a good error message.Dockerfile:
Gemfile:
Gemfile.lock:
test.rb