-
Notifications
You must be signed in to change notification settings - Fork 798
Add option to not install existing versions #543
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
Conversation
The -f option allows for forcing installation of versions that already exist in the environment. If that option isn't used, then an interactive prompt is created which causes problems for non-interactive execution of the command. One could use -f for non-interactive executions, but it causes a significant slowdown in runtime if you don't want to reinstall that version. This change allows for a -n option to not install versions that already exist, while still exiting with a happy status code (for cases where scripts may be kicking off the rbenv install command where `set -e` has been run).
|
Additionally, I'm open to changing the option's name. I used |
|
The following doesn't cut it? RBENV_VERSION="$version" rbenv which ruby &>/dev/null || rbenv install $versionI would like to avoid adding the option if possible. It just feels awkward. |
|
I've wanted this option before. +1 Can we come up with a better name than |
|
@sstephenson Does |
|
How about SKIP_EXISTING? |
|
@mislav Sounds better. I'd suggest |
|
|
|
Do it! |
|
updated! |
|
@sstephenson Do we want to run post-install hooks? |
|
No need to run post-install hooks if the version has already been installed. |
|
Thanks @kmwhite! |
The -f option allows for forcing installation of versions that already
exist in the environment. If that option isn't used, then an interactive
prompt is created which causes problems for non-interactive execution of
the command. One could use -f for non-interactive executions, but it
causes a significant slowdown in runtime if you don't want to reinstall
that version.
This change allows for a -n option to not install versions that already
exist, while still exiting with a happy status code (for cases where
scripts may be kicking off the rbenv install command where
set -ehasbeen run).
This command stemmed from using rbenv in our CI setup. We wanted to install the ruby version, of each app but each run failed if we already had the ruby version installed. We wound up with a lengthy
if-elsestanza to try installing the version and ignore errors if they matched the pattern for an already installed version or properly breaking the build if there were installation errors. I realized this was a simpler answer.If there is another, better, existing solution, I'm all ears. I couldn't figure one out. :\