Create A Gemset with RVM

It's important to keep the dependencies of your applications separate from each other to avoid version discrepancies and massive headaches. Most of your Ruby programs utilize gems for basic utilities and functionality.

Having two different applications that require two versions of the same gem would cause you a headache without a tool like this. You would either need virtualized development environments for each application or you would need to install the correct version every time you worked on the other application.

Just don't.

You're better off using RVM to separate each app's dependencies.


A Gemset is exactly what it sounds like, a specific set of gems for your current development environment.

Personally, I use a basic Gemset that carries all of my computer's utilities, such as Sass and some other command line tools, along with a completely separate gems for each program or application that I'm building.

So here's an example. I clone an application repository called myapp and now I need to run it. I have ruby-2.2 installed on my system but this application requires ruby-1.9.3. No problem, RVM to the rescue.

First we can install Ruby 1.9.3 by typing the following:

rvm install ruby-1.9.3

Once that command has finished we can switch to that freshly installed version by running the following command:

rum use ruby-1.9.3

Now we're ready to create our new Gemset with RVM.

Type the following command in to your terminal:

rvm gemset create myapp

Next, we use the following command to switch to the Gemset we just created. After that we can install our dependencies.

rvm use ruby-1.9.3@myapp

Pretty nifty, huh? To get back to my original environment, I could run the command:

rvm use ruby-2.1.1@default

Those are the basics behind a Gemset, but there is more where that came from. Check out how to create an Alias over at the official RVM website.

You can use an Alias to bundle together different versions of RVM Ruby with different Gemsets as a whole package.