Automatic rvm gemsets

03 Oct 2010 . . Comments

I’ve been using Ruby version manager (rvm) for a while now, but hadn’t really been paying too much attention to its new features. Over the weekend, I ran in to perhaps one of the coolest new features: project-level configurations. Essentially this allows you to set up your Ruby project to automatically switch gemsets when you enter the directory with the terminal.

To try this out, I created a new gemset and then told my project about it:

rvm gemset create project_name
cat "rvm ruby@project_name" > path/to/project/.rvmrc

Now, when you cd in to the directory, rvm will automagically switch gemsets for you. No more firing up rails only to get the error message that you don’t have the right rubies installed. Great time saver, and if you’re managing projects that aren’t using bundler yet, a real time saver!