postmodern / ruby-install

Installs Ruby, JRuby, TruffleRuby, or mruby
MIT License
1.91k stars 255 forks source link

Feature Request: check versions before install #420

Open tir38 opened 2 years ago

tir38 commented 2 years ago

I can run the installer twice in a row and it'll duplicate much of the work. It would be helpful if ruby-install could check if a version is installed already before running through the whole install process.

postmodern commented 2 years ago

We already have a --no-reinstall flag which checks for the existence of $install_dir/bin/ruby, prints a warning and exits. We could make this behavior the default behavior, and require --reinstall or --overwrite option flags to force ruby-install to re-install over an existing ruby install.

tir38 commented 2 years ago

I think adding something to the README would be good enough, although I see there is already an open issue to do that: https://github.com/postmodern/ruby-install/issues/266

todd-a-jacobs commented 1 month ago

I have a Fish function that's easily converted to Bourne-like shells (mostly the array logic and regexp pattern matching currently leverage Fish rather than external utilities like grep or known Bashisms) that could check the current list of Rubies reported by chruby against the latest as reported by ruby-install. I'm deliberately going through the existing utilities rather than looking at the filesystem directly as a convenience and a useful (to me) abstraction that keeps chruby and ruby-install as the authoritative source of versions under their management. Happy to share the relevant snippets so people can kick the tires, or to try to add the code directly as a PR if it's a desirable feature.