Exposing hidden Rubies for firewalled RVMs

Using chruby with RVM::FW

chruby is an alternative environment manager to RVM. It is the least intrusive environment manager and is very well suited to system wide and production environment ruby installs.

The initial installation of chruby needs to be run either as the root user or with sudo privileges:

Installing chruby

# Download chruby with wget
$ wget -O chruby-0.3.9.tar.gz http://rvm-fw.herokuapp.com/rubies/packages/chruby/chruby-0.3.9.tar.gz
$ tar xzvf chruby-0.3.9.tar.gz
$ cd chruby-0.3.9
$ ./scripts/setup.sh

Once chruby is installed you need to source it either server-wide or on a per-user basis. To expose chruby to all users on the server add the following to the /etc/profile.d/chruby.sh file:

# /etc/profile.d/chruby.sh
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
  source /usr/local/share/chruby/chruby.sh
# Set MRI Ruby 2.2.2 as the default ruby on login
if [ -d "/opt/rubies/ruby-2.2.2" ]; then
  chruby 2.2.2

To enable chruby on a per-user basis instruct each user to add the following to their profile file:

# ~/.bashrc
source /usr/local/share/chruby/chruby.sh
# Set MRI Ruby 2.2.2 as the default ruby on login
chruby 2.2.2

After you've implemented loading chruby, restart your terminal / shell session.

Installing ruby-install

# Download ruby-install with wget
$ wget -O ruby-install-0.5.0.tar.gz http://rvm-fw.herokuapp.com/rubies/packages/chruby/ruby-install-0.5.0.tar.gz
$ tar xzvf ruby-install-0.5.0.tar.gz
$ cd ruby-install-0.5.0
$ sudo make install

Installing Rubies with chruby

Installing rubies with chruby and RVM::FW is easy. Simply copy the URL for the ruby you want to install from the RVM::FW Rubies page and then use that URL:

# System wide ruby installation
sudo ruby-install --no-verify -u http://rvm-fw.herokuapp.com/rubies/ruby-lang/2.2/ruby-2.2.2.tar.bz2

# Single user installation
ruby-install --no-verify -u http://rvm-fw.herokuapp.com/rubies/ruby-lang/2.2/ruby-2.2.2.tar.bz2

Once you've installed a ruby you can change rubies and verify it installed properly with:

$ chruby 2.2.2
$ ruby -v
#=> ruby 2.2p95...