Categories
Rails Ruby

How to use a specific Ruby version and set of gems for a Rails 3 app using RVM

This is very useful when you have multiple apps and you might get confused with which gems are installed on which project.

First, if you don’t have RVM installed, look at this post:

Now lets create the .rvmrc file, through the Terminal, that must go in the root of your app (main folder), but first you have to decide which Ruby version you want to use with your app, to list them run:

rvm list known

In my case, I will install the latest 1.9.2 version (be sure to change “yourprojectname” with yours – this is called gemset, where you gems will reside):

rvm --rvmrc --create 1.9.2@yourprojectname

After that “cd ..” out of your app and then “cd yourprojectname” in, you will be asked if you want to use the .rvmrc file that has been found inside the root of your app, type “y” and hit Enter.
Then you’ll have to install the Ruby version you selected, in my case I’d run:

rvm install 1.9.2

Since its a fresh gemset (no gems installed), you will have to run:

gem install bundler

And then run:

bundle install

Leave a Reply