Skip to content

Conversation

@kmwhite
Copy link

@kmwhite kmwhite commented Apr 4, 2014

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).

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-else stanza 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. :\

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).
@kmwhite
Copy link
Author

kmwhite commented Apr 4, 2014

Additionally, I'm open to changing the option's name. I used -n and NOFORCE to indicate the opposite of the existing -f option, but it's an odd name. Maybe -s and SKIP_INSTALLED ?

@mislav
Copy link
Member

mislav commented Apr 4, 2014

The following doesn't cut it?

RBENV_VERSION="$version" rbenv which ruby &>/dev/null || rbenv install $version

I would like to avoid adding the option if possible. It just feels awkward.

@sstephenson
Copy link
Contributor

I've wanted this option before. +1

Can we come up with a better name than NOFORCE?

@kmwhite
Copy link
Author

kmwhite commented Apr 4, 2014

@sstephenson Does SKIP_INSTALLED work for you?

@mislav
Copy link
Member

mislav commented Apr 4, 2014

How about SKIP_EXISTING? -e/--skip-existing externally

@kmwhite
Copy link
Author

kmwhite commented Apr 4, 2014

@mislav Sounds better. I'd suggest -s for consistency with matching the first character of the long form name like the other options do, but I'm not married to either.

@sstephenson
Copy link
Contributor

-s/--skip-existing sounds great 👍

@mislav
Copy link
Member

mislav commented Apr 4, 2014

Do it!

@kmwhite
Copy link
Author

kmwhite commented Apr 4, 2014

updated!

@mislav
Copy link
Member

mislav commented Apr 4, 2014

@sstephenson Do we want to run post-install hooks?

@sstephenson
Copy link
Contributor

No need to run post-install hooks if the version has already been installed.

@mislav mislav closed this in c114885 Apr 4, 2014
@mislav
Copy link
Member

mislav commented Apr 4, 2014

Thanks @kmwhite!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants