Last Updated: February 25, 2016
·
1.031K
· jmitchell

Use .rvmrc for your Ruby project directories

If you're an avid RVM (Ruby Version Manager) user, you're probably already familiar with this strategy.

For everyone else who needs to use multiple versions of Ruby and gems on the same machine for different projects check out RVM. RVM can install pretty much any version of Ruby and makes it easy to install gems in separate partitions called RVM gemsets. Now you've got the machinery to switch between various Ruby versions and gemsets with a simple shell command.

This is great, but doing such a mindless task every time you open a project directory gets old fast. To fix that, make project-specific .rvmrc files! As described in this StackOverflow answer, simply make an .rvmrc file in the root project directory with

rvm  [RUBY_VERSION[@[GEMSET_NAME]]

For more information, refer to the rvmrc page on the RVM website, particularly the "Project .rvmrc" section.