Using chruby and ruby-build to Manage Ruby Installations by dunsmoreb
RVM has been the traditional choice of #ruby management for years.
Such a heavyweight isn't always required though and a lighter alternative is desirable. We can achieve this setup with the tools chruby and ruby-build.
With chruby we can manage multiple Ruby versions; ruby-build allows us to install multiple Ruby versions.
Managing Rubies with chruby
chruby is a lightweight environment manager. It sets environment variables and nothing else. This gives us more freedom about where we put our Rubies and how we install them.
chruby can be installed with these steps:
wget -O chruby-0.3.4.tar.gz https://github.com/postmodern/chruby/archive/v0.3.4.tar.gz
tar -xzvf chruby-0.3.4.tar.gz
cd chruby-0.3.4/
make install
We then source chruby inside of our ~/.bashrc or ~/.zshrc.
source /usr/local/share/chruby/chruby.sh
Building Rubies with ruby-build
ruby-build is a tool to compile and install multiple Ruby versions. It allows us to install Rubies wherever we want and with many options.
Available Rubies can be found with:
ruby-build --definitions
chruby looks for Rubies in /opt/rubies. This is where we should install all of our Rubies.
To install Ruby 1.9.3-p392 we would run:
ruby-build 1.9.3-p392 /opt/rubies/ruby-1.9.3-p392
Wrap-up
A Ruby can then be selected with chruby <ruby>.
chruby rubinius-1.2.4
chruby
ruby-1.9.3-p392
* rubinius-1.2.4
To set the default Ruby use chruby to select it inside of your ~/.bashrc or ~/.zshrc.
source /usr/local/share/chruby/chruby.sh
chruby ruby-1.9.3-p392
Learn More
More information about chruby and ruby-build is available on GitHub.
Comments
No comments yet