Towards Simplicity: From rbenv to chruby
chruby is a Ruby version manager: a tool that makes easy to switch Ruby
version along with the context either on a local directory or system-wide
basis. What makes
chruby stand out is its design simplicity. Also, it has
only ~90 LoC.
rvm may seem unnecessarily complicated. The former operates on shims
and does context switching each time any Ruby or gem binary is executed. It
requires to run
rbenv rehash each time there is a new binary installed. The
cd command for that purpose (hence it is done only once), but
it can also install Ruby, manage gemsets and more. Those additions make
feel heavy and complex.
chruby uses PROMPT_COMMAND to switch the context.
chruby can be installed in various ways. For OSX, it is as simple as:
brew install chruby
Next, add the two following lines to your shell profile file (
source '/usr/local/share/chruby/chruby.sh' source '/usr/local/share/chruby/auto.sh'
λ brew install ruby-build λ ruby-build 1.9.3-p392 ~/.rubies/ruby-1.9.3-p392 λ ruby-build jruby-1.7.3 ~/.rubies/jruby-1.7.3
To see a list of available Ruby versions, type:
To switch between Ruby versions, type:
λ chruby jruby-1.7.3 λ chruby ruby-1.9.3
To use the system Ruby, type:
λ chruby system
To set default Ruby, put the following line inside your shell profile file
λ chruby ruby-1.9
To specify local, per-project Ruby version, put its name inside
file in that project directory.
chruby provides the most elegant way to manage Ruby versions. It does
only one thing, without unnecessary additions and complications.
My Tech Newsletter
Get emails from me about programming & web development. I usually send it once a month