Have shims survive upgrades via Homebrew #1350
Merged
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.
Homebrew places the rbenv executable in a location such as
/usr/local/bin/rbenv
, which is in PATH. However, that is a symlink to/usr/local/Cellar/rbenv/<VERSION>/bin/rbenv
, which is itself a symlink to/usr/local/Cellar/rbenv/<VERSION>/libexec/rbenv
. Upon executing, rbenv will add its own directory to PATH so that it can easily invoke its subcommands.When generating shims during
rbenv rehash
, rbenv will try to put the absolute path to itself inside each shim so that shims would work even if rbenv itself isn't in PATH. Under Homebrew, rbenv's directory will be the versioned directory in Homebrew's Cellar. However, due to Homebrew's auto-cleanup functionality, shims generated this way will be broken after upgrading rbenv because of the versioned Cellar path.This changes how rbenv discovers itself in PATH: it will look at the original PATH, not in the one modified by rbenv, with the intention of excluding results under rbenv's own
libexec/
. If rbenv wasn't found in PATH, return the absolute path to rbenv's ownbin/rbenv
.