chruby
chruby copied to clipboard
Change ruby automatically after install via ruby-install
I'm trying to make a script that will keep my command line up to date. What I want to do is I want to install ruby with ruby-install
(ruby-install --latest ruby --no-reinstall
), and if there is a new version and it installs it, I want to change ruby to that version with chruby
. Is there a way to do that now, am I missing something? I couldn't piece it together from help pages
I think this is a variant of #217.
... or, maybe not a variant, but I think #217 is at least blocking this from ever working in the case where it installs a new version.
Maybe the top of chruby.sh (setting RUBIES
) should be turned into a shell function which doesn't use memoization? This would allow resolving both #217 and this issue, and would eliminate having to discard terminals/processes to update RUBIES
. Plus, it would be execute lazier and the filesystem IOPS overhead would be minimal.
I made a little shell function for myself. Maybe this is all you need? You can change it to add the default CLI gems you like
# Use like: $ chruby-install 2.6.3
function chruby-install {
ruby-install --src-dir /tmp --cleanup --no-install-deps ruby $1 && \
source ~/.profile && \
chruby $1 && \
gem update --system && \
gem install --no-document rails rake bundler rack foreman down
}