Project Gemsets with RVM

I use RVM, the Ruby Version Manager, because I often switch between projects that require different versions of Rails. I create an RVM gemset for each project.

RVM looks for a .rvmrc file in a project root directory and automatically switches to the required version of Ruby and the correct gemset. Now, with version 1.19, RVM looks for files named .ruby-version and .ruby-gemset in the root directory. RVM will prompt you to replace the .rvmrc file with the two new files. It’s a worthwhile change, for several reasons. Unlike the .rvmrc file, the two new files contain no shell commands so they don’t need “trusting” and performance is faster. The .ruby-version file is also recognized by other Ruby version switchers such as chruby or rbenv (though the .ruby-gemset file is unique to RVM). I’m delighted to see movement toward a unified standard. A big thanks to Fletcher Nichol (fnichol) for initiating the unification effort.

The Rails Composer tool and the rails_apps_composer gem now create the .ruby-version and .ruby-gemset files when you generate a starter application. I’m upgrading the RailsApps example applications as well.

Here’s details for users making the transition to the new files. If you have a simple .rvmrc file:

rvm use ruby-2.0.0@myapp

It can be transformed to .ruby-version:

2.0.0

And .ruby-gemset:

myapp

Be sure to remove the .rvmrc file as it takes precedence over any other project configuration files:

rm .rvmrc

Keep in mind that if you’ve extended your .rvmrc file with custom shell commands you won’t be able to replace it. No worries though, as RVM will continue to recognize the .rvmrc file.

For details on how RVM gets configured per project, see a discussion.

Now is a good time to say thank you to Michal Papis (@mpapis) for his efforts to improve RVM. As a utility, RVM is not an official part of Rails but it greatly improves the day-to-day developer experience.

2 notesShowHide

  1. rails-apps posted this