Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy 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

Merged

Conversation

jf
Copy link
Contributor

@jfjf commentedJan 8, 2020

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 ofrbenv version,rbenv versions, andrbenv version-name can be misleading, and point to a missing rbenv version file.

Copy link
Member

@mislavmislav left a 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, theset by ~/.rbenv/version message has two meanings:

  1. The current value wasread from that file. (This is not exactly true if the file is missing; "system" is merely a default value.)
  2. 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 showsystem (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 withrbenv-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 forrbenv-version-origin.)

What do you think about a compromise along the lines of:

## rbenv-versionversion_name="$(rbenv-version-name)"version_origin="$(rbenv-version-origin)"if ["$version_origin"="${RBENV_ROOT}/version" ]&& [!-e"$version_origin" ];thenecho"$version_name (something useful as fallback here)"elseecho"$version_name (set by$version_origin)"fi

What would be a good fallback message (ideally something other than just no explanation)?

@jf
Copy link
ContributorAuthor

jf commentedJan 12, 2020

What about something like (to give an example):

system (default; use /home/jf/.rbenv/version to set)

?

mislav reacted with eyes emoji

@mislav
Copy link
Member

mislav commentedJan 14, 2020
edited
Loading

@jf Sorry for late reply. Let's just saysystem (nothing in parentheses) for now ifRBENV_ROOT/version is missing, since I can't think of anything better.

If we wanted to be more user-friendly, then when the user runsrbenv version and no global version is set, we can suggest that they set a global version other than "system" (since they likely don't want to be using "system" when installing gems). But that's a totally different feature and probably out scope for your original fix.

@jf
Copy link
ContributorAuthor

jf commentedJan 14, 2020

I did suggest a message; that didn't work for you?

If we just saysystem with no message after, we're back torbenv-version-origin returning nothing, fyi.

@mislav
Copy link
Member

mislav commentedJan 15, 2020
edited
Loading

I did suggest a message; that didn't work for you?

Yours was a good suggestion; I just think that we shouldn't really sayuse /home/jf/.rbenv/version to set because we don't expect the user to write to this file directly - instead we want them to userbenv global <version>.

Perhaps rbenv should be better at across the board suggesting that a person edits the current version in play by usingrbenv global,rbenv local, andrbenv shell. But that's an improvement for another PR.

If we just saysystem with no message after, we're back torbenv-version-origin returning nothing, fyi.

Well, following my suggestion above, I think that we can leaverbenv-version-origin intact as before your change, and instead implement this inlibexec/rbenv-version:

version_name="$(rbenv-version-name)"version_origin="$(rbenv-version-origin)"if ["$version_origin"="${RBENV_ROOT}/version" ]&& [!-e"$version_origin" ];thenecho"$version_name"elseecho"$version_name (set by$version_origin)"fi

I think this approach is safer becauserbenv version is meant more for human consumption, so we can tweak it, andrbenv-version-origin could be potentially used in scripts, so it's better to leave the latter intact.

@jf
Copy link
ContributorAuthor

jf commentedJan 15, 2020

ok, I see (sorry, I got a bit confused there). I'm ok with this: should I push another commit with this then?

@mislav
Copy link
Member

@jf Yes please! You may even force-push if you want a cleaner history

@jf
Copy link
ContributorAuthor

jf commentedJan 16, 2020

:) I prefer the history as is; I'm pushing more commits as we speak.

Copy link
Member

@mislavmislav left a 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!

@mislavmislav merged commit7795476 intorbenv:masterJan 16, 2020
gioele pushed a commit to gioele/rbenv that referenced this pull requestFeb 15, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mislavmislavmislav approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@jf@mislav

[8]ページ先頭

©2009-2025 Movatter.jp