chruby icon indicating copy to clipboard operation
chruby copied to clipboard

Change ruby automatically after install via ruby-install

Open akaralar opened this issue 7 years ago • 4 comments

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

akaralar avatar Aug 13 '16 00:08 akaralar

I think this is a variant of #217.

aprescott avatar Aug 13 '16 01:08 aprescott

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

aprescott avatar Aug 13 '16 01:08 aprescott

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.

skull-squadron avatar Nov 11 '16 08:11 skull-squadron

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
}

csuhta avatar Jun 05 '19 19:06 csuhta