-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libexec/rbenv-version: get rid of misleading "set by $(rbenv-version-origin)" message when system ruby is in use #1203
libexec/rbenv-version: get rid of misleading "set by $(rbenv-version-origin)" message when system ruby is in use #1203
Conversation
…origin)" message when system ruby is in use
…V_VERSION env var
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.
Thank you! I can certainly see how "set by FILE" can be misleading if FILE doesn't exist.
However, the set by ~/.rbenv/version
message has two meanings:
- The current value was read from that file. (This is not exactly true if the file is missing; "system" is merely a default value.)
- Writing to that file allows you to change the version. This is true regardless of whether the file exists or not.
If we don't show system (set by ${RBENV_ROOT}/version)
by default anymore, I worry that people will not understand that this file, if created, dictates the global version.
Additionally, I'm not comfortable with rbenv-version-origin
possibly yielding no output. The caller is then forced to guess what the no-output case means. (Reminder that plugins and other scripts may also consume the output for rbenv-version-origin
.)
What do you think about a compromise along the lines of:
## rbenv-version
version_name="$(rbenv-version-name)"
version_origin="$(rbenv-version-origin)"
if [ "$version_origin" = "${RBENV_ROOT}/version" ] && [ ! -e "$version_origin" ]; then
echo "$version_name (something useful as fallback here)"
else
echo "$version_name (set by $version_origin)"
fi
What would be a good fallback message (ideally something other than just no explanation)?
What about something like (to give an example):
? |
@jf Sorry for late reply. Let's just say If we wanted to be more user-friendly, then when the user runs |
I did suggest a message; that didn't work for you? If we just say |
Yours was a good suggestion; I just think that we shouldn't really say Perhaps rbenv should be better at across the board suggesting that a person edits the current version in play by using
Well, following my suggestion above, I think that we can leave version_name="$(rbenv-version-name)"
version_origin="$(rbenv-version-origin)"
if [ "$version_origin" = "${RBENV_ROOT}/version" ] && [ ! -e "$version_origin" ]; then
echo "$version_name"
else
echo "$version_name (set by $version_origin)"
fi I think this approach is safer because |
ok, I see (sorry, I got a bit confused there). I'm ok with this: should I push another commit with this then? |
@jf Yes please! You may even force-push if you want a cleaner history |
…ection" logic as per @mislav
:) I prefer the history as is; I'm pushing more commits as we speak. |
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.
Looks great, thank you for your patience!
as per message: it can be that when the system ruby is in use that there simply is no rbenv version file. However, the output of
rbenv version
,rbenv versions
, andrbenv version-name
can be misleading, and point to a missing rbenv version file.