-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't try to allow overriding with rbenv shell
* I can't find a way to recognize a custom RBENV_VERSION when this hook * runs, since RBENV_VERSION is always populated regardless.
- Loading branch information
Showing
2 changed files
with
1 addition
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67c64e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could query version-origin to see where RBENV_VERSION was set from. It would emit
if by shell:
if global:
(and if global, you could query whether the version is 'system' or a real rbenv version)
67c64e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasonkarns that has the same problem as the code above, since rbenv-version-origin just checks RBENV_VERSION anyway, and RBENV_VERSION is always set to the currently-prioritized rbenv version before this script would get run: https://github.com/sstephenson/rbenv/blob/9e664b5d27cd7b2bdb94a9ec8ce55c32ebe1ad7a/libexec/rbenv-which#L36
67c64e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line referenced above sets RBENV_VERSION for the current shell, but it's not exported. You would be invoking
rbenv-version-origin
in a subshell, so RBENV_VERSION would not be set.As I went about verifying this, I realized that since we need to invoke a subshell anyway, we may as well just query for an exported RBENV_VERSION itself, rather than going through the roundabout version-origin. So I verified that
local env_var="$(echo $RBENV_VERSION)"
and it does. But then I realized that rbenv-bundler-ruby-version itself is executed in a subshell from thewhich
hook. So RBENV_VERSION is only set in the context of rbenv-bundler-ruby-version when it has been exported by the user. So this commit can be reverted. It works just fine. (I tested locally)