I'm learning how to set up different versions of ruby with different versions of rails using rvm. Here's a link for the instructions http://beginrescueend.com/gemsets/basics/. It says

Let's say, for example, that you are testing two versions of a gem, with ruby 1.9.2-head. You can install one to the default 1.9.2-head, then create a named gemset for the other version, and switch between them easily. Example: testing gems

$ rvm 1.9.2-head@testing

will use a '1.9.2-head@testing' GEM_HOME (be sure to create it

first), whereas:

I have already created

rvm install 1.8.7-head
rvm install 1.9.2

but how do I create this rvm 1.9.2-head@testing.

There's something I don't get about the instructions... Please clarify if you can.



What is a Gemset?

I have already created

rvm install 1.8.7-head
rvm install 1.9.2

With this, you installed two Rubies (not Gemsets), namely versions 1.8.7 and 1.9.2. These are (simply speaking) just two versions of the Ruby interpreter/language.

Now, each Ruby version normally has a couple of Gems installed (Rails being one). Think of it as a plug-in. In the normal case, you only have one set of plugins for the Ruby on your system. With RVM however, you can configure it to use multiple "Gemsets" per Ruby version. Thus, you can use multiple Ruby versions (e.g. Ruby 1.8.7 and 1.9.2) and have each of them use different Gemsets.

In your case, maybe you want to have two Gemsets for each of your versions:

enter image description here

In addition to Gemsets you create, each Ruby also has a "default" Gemsets. This is the one you get when you don't supply any Gemset name while switching. All of them share one "global" Gemset as well.

How do you create a Gemset?

How do you create such a "testing" Gemset?

As per the manual, first, switch to the Ruby version you want to use:

rvm 1.9.2

… and then create the Gemset, in your case "testing". The part about GEM_HOME, well, forget it. The manual doesn't mention how to create it. You have to read a bit further down to the example:

rvm gemset create testing

Now your Ruby 1.9.2 will have a Gemset called "testing", which you can switch to with

rvm 1.9.2@testing

Now, any Gem you install with gem install will reside in this particular Gemset. If you create another Gemset (using rvm gemset create) and switch to that, the previously installed Gem will not be available, as you're working in another Gemset now.

  • Thank you so much. I ran into another problem starting server in these new rvm set ups. if you have time I'd be very grateful. I posted a question at superuser.com/questions/340598/… – Michael Sep 27 '11 at 22:48
  • I'll have to check tomorrow. Seems like a cache or incompatibility thing, not sure! – slhck Sep 27 '11 at 22:56
  • o.k., thanks a lot if you have time tomorrow. I appreciate your help. – Michael Sep 27 '11 at 23:02
  • Also note, each ruby also has a "default" gemset, which is what you get when you don't specify any gemset by name; and a "global" gemset, which you can switch to and install gems that show up in all gemsets. – Andrew Vit Sep 28 '11 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.