RVM gemsets are distinct across Ruby versions

I’ve been “using” RVM for the last two years or so on the job, initially to install Ruby version 1.9.1, and later to upgrade to version 1.9.3. Since I only developed the single work app on my laptop, I had no use for RVM’s gemsets (nor was I actually aware of them). I finally found a reason to create a second Rails app, and wanted to try out Rails 4 (the work app was still using Rails 3). This is exactly what RVM is useful for! A great introductory write-up for the Ruby Version Manager (RVM) is available at Ruby Version Manager (RVM) Overview for Rails Newbs.

The particular thing I got out of the article that I hadn’t realized about RVM before is that it’s good for managing disparate sets of gems (coincidentally referred to as “gemsets”). One slight point of confusion for me was understanding that gemsets are distinct across Ruby versions, even if they have the same name. It seems painfully obvious in hindsight, but was less clear when I was still figuring out what the point of RVM is.

Visualizing the relationship between Ruby versions and gemsets as in the diagram below helped me:

RVM gemsets diagram

Using gemsets, I could keep the gems used by my work app running Rails 3 and Ruby 1.9.3 separate from an experimental app running Rails 4 in either Ruby 1.9.3 and Ruby 2.0.0.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s