(It so happens I’m presenting this at Dallas.rb tonight. Hopefully it can also be useful to those out in internetland too.)
RVM gives you three things:
- an easy way to use multiple versions of multiple Ruby VMs
- the ability to manage multiple indpendent sets of gems
- more sanity
First, let’s install RVM:
gem install rvm
- follow the directions to integrate with your shell of choice
Now, let’s install some Rubies:
rvm list knownwill show us all the released Rubies that we can
install (more on list)
rvm list rubieswill show which Rubies we have locally installed
rvm install ree-1.8.7gives me the latest release of the 1.8.7
branch of Ruby Enterprise Edition
rvm install jrubywill give me the default release for JRuby
rvm use jrubywill switch to JRuby
rvm use reewill give me Ruby Enterprise Edition
rvm use ruby-1.8.6will give me an old and familiar friend
rvm use systemwill put me back wherever my operating system left
The other trick that RVM gives us is the ability to switch between
different sets of installed gems:
- Each Ruby VM (JRuby, Ruby 1.9, Ruby 1.8, REE) has its own set of
gems. This is a fact of life, due to differing APIs and, you know,
rvm use ruby-1.9.1gives you the default Ruby 1.9 gemset
rvm use ruby-1.9.1%acmegives you the gemset for your work with
Acme Corp (more on using gemsets)
rvm use ruby-1.9.1%waynegives you the gemset for your work with
rvm use ree%awesomegives you the gemset for your awesome app
- You can export and import gemsets. This can come in handy to bring
new people onboard. No longer will they have to sheepishly install
gems on their first day as they work through dependencies you long
since forgot about.
Some other handy things to peruse:
I also promised you some extra sanity:
- RVM knows how to compile things, put Rubygems and rake in place, even apply patches and pull from specific tags. You can do more important things, like watch The View or read an eleven part series on pre-draft analysis for the Cowboys.
- RVM lets you isolate different applications you’re working on. Got one app that doesn’t play nice with Rails 2.x installed? No problem, create a gem environment for that! Stuck in the spider-web of Merb dependencies? Isolate it in its own environment.
- RVM makes multi-platform testing and benchmarking easy. You can easily run your test suite or performance gizmo on whatever Rubies you have installed.
- RVM makes it easy to tinker with esoteric patchlevels and implementations. For instance, feel free to tinker with MagLev or the mput branch of MRI.
A couple other things RVM tastes great with:
- Using homebrew to manage packages instead of MacPorts
- Not using
sudoto install your gems
- Managing your dotfiles on GitHub
One thought on “A quick RVM rundown”
put something like the following line into /your/project/dir/.rvmrc
This will auto-switch to the specified ruby/gemset when cd-ing into that directory..
Comments are closed.