The Ruby VM market is thriving, and we increasingly find ourselves spending the morning in JRuby and the afternoon in Ruby Enterprise Edition.
Or Thursday using Leopard Ruby and Friday using Ruby 1.9.
Or ... well, you get the idea.
So we needed a lightweight tool that eliminates the cost (in both time and frustration) of switching between Ruby versions.
We wanted something drop-dead simple.
Meet the Ruby Switcher.

Hello, Ruby Switcher

The Ruby Switcher debutedearlier this year as a means for toggling between a handful of pre-installed Ruby versions.
And once you bit the bullet and manually installed those VMs,
and assuming you installed them in the "right" location,
the Ruby Switcher offered crazy-fast switching between those few Ruby versions.
But we're passionate about continuous improvement and maintaining a sharp set of tools,
so we recognized that switching Ruby versions was Step 2;
Step 1 (i.e., installing those Ruby versions in the first place) needed a healthy dose of automation as well.
Today's Ruby Switcher makes both steps insanely simple,
and it adds support for more (and newer) Ruby versions as well.

Pick a Ruby, Any Ruby

Enough talk! Let's download the Ruby Switcher and get this party started.

That's it.
Let's quickly verify that you have your platform's core developer tools installed,
and then you'll be ready to put the Ruby Switcher to work.

Prerequisites - Compilers, Libraries, and Whatnot

If you're on OS X, you'll need to download and install Xcode.
(If you just want to switch between Leopard Ruby and JRuby, you can skip this step.
If you want to use any other versions of Ruby, you'll need Xcode.)

By the time you're done reading through the Ruby 1.9 highlights,
you'll be ready to take it for a spin.
Type ruby -v to verify that you're rockin' with 1.9.1.

ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]

JRuby

Installing and using JRuby is just as easy.

First, be sure that you have the JDK installed.
If you're using OS X, you're all set.
If you're on Ubuntu, you can install it with apt-get.
(For other Linux distros, you can ask your native package manager for the JDK bits.)

Wait a minute: shouldn't we have typed jruby -v instead of ruby -v?
Sure you can do that if you really want to.
But we're not big on having to remember to type jirb instead of irb, or jgem instead of just gem, etc.
Once we tell the shell to use JRuby, we want the normal Ruby commands to just work.
The Ruby Switcher ensures that they do.

Ruby.*

Looking for yet another Ruby version?
See what else the Ruby Switcher has to offer:

install_ree_186

install_ruby_186

install_ruby_187

install_jruby_120

And if you find yourself wanting some other Ruby variant,
be sure to check out the Ruby Switcher's internals;
you can likely adapt one of the existing installation functions to meet your exact need.

Willy-nilly Switching

Once you have the desired Ruby versions installed,
switching between them couldn't be easier.
Each of the install commands comes with a corresponding use command to instruct your shell to switch to the specified Ruby version:

Install It

Use It

install_ruby_191

use_ruby_191

install_ruby_186

use_ruby_186

install_ruby_187

use_ruby_187

install_jruby

use_jruby

install_jruby_120

use_jruby_120

install_ree_186

use_ree_186

N/A [1]

use_leopard_ruby

And these commands are shell-specific!
So while one terminal window is using Ruby 1.8.7 to run your front-end Rails app,
you can have another terminal using JRuby to run your back-end messaging code.

Ruby 1.9, the Community, and You

Want to see whether your app runs on Ruby 1.9?
Flip your shell to use_ruby_191 and try it out.
It's that kind of experimentation that will allow the Ruby community to make the migration to Ruby 1.9.

See a problem with a certain gem on Ruby 1.9?
Let the gem author know about it and chime in at isitruby19.com.
Better yet, write a test that proves the bug and pass that test along to the author.
Better still, fix the issue and submit a patch.
Any one of these steps moves us forward,
and all the while you've still got your default Ruby installation standing safely by for your day job.

When switching between Ruby versions is this seamless, there's no reason not to experiment.

Notes

[1] Ruby is installed by default on OS X Leopard, so there's no need for an install_leopard_ruby command.