tags:

views:

51

answers:

1

I am really confused by the explanations given in RVM website. The relation between different ruby interpretors and gemsets are not clear to me. According to me, it is like this -

  1. My Account in my Mac have one rvm
  2. That rvm installs and manages set of different versions of ruby interpretors.
  3. each ruby version has set of gemsets.

Am i getting things clear... Any more amount of explanations are welcome. I am in a position to work on (Ruby 1.8.7 + rails 2.3.8 and its dependencies) and (Ruby 1.9.2 and Rails 3.0 and its dependencies)...

If any one is well versed with handling many ruby versions and gemsets with the help of rvm, please explain to me... thanks for the help

+1  A: 

Here is how I like to do it...

  1. Install a ruby with RVM
  2. Switch to/use that ruby
  3. Create a gemset for a project
  4. Switch to/use that gemset
  5. Install gems needed
  6. create an alias that points to my chosen ruby & gemset
  7. switch to/use that new alias (again, associated w/ a project)

Do this as many times necessary for your different projects that you want to keep separate from eachother.

Example:

$ rvm install ruby-1.9.2
...
$ rvm list

rvm rubies

=> ree-1.8.7-head [ i386 ]
   ruby-1.9.2-head [ i386 ]
   ruby-1.9.2-preview3 [ i386 ]

$ rvm use ruby-1.9.2-preview3

info: Using ruby 1.9.2 preview3
$  rvm gemset create my_project

info: Gemset 'my_project' created.
rvm gemset use my_project

info: Now using gemset 'my_project'
$ gem install httparty
When you HTTParty, you must party hard!
Successfully installed crack-0.1.8
Successfully installed httparty-0.6.1
2 gems installed
$ rvm alias create my_project ruby-1.9.2-preview3@my_project

info: Creating alias my_project for ruby-1.9.2-preview3@my_project.

info: Recording alias my_project for ruby-1.9.2-preview3@my_project.
$ rvm use my_project

info: Using ruby 1.9.2 preview3 with gemset my_project
$ ....

Now I have an entire environment dedicated to a particular project. This is great because I can experiment with all sorts of different gems/versions without worrying about stomping all over other projects that have very specific requirements.

Good luck!

Brian
if i go and work in a different gemset , those gems which are installed in my system or those which are installed in other gemsets are not available... right ??
lakshmanan
Thanks a ton Brian - I fully understood now - the workflow and the gemset concept...thank a lot again
lakshmanan
Glad it helped. It took me a little bit to 'get it' as well. Now, I can't live without it... Which reminds me, I should probably go donate to the RVM project...
Brian
I didn't know about the alias part of the workflow. you just saved me some serious typing. Also, from what i've recently discovered, when you update rvm, it may point to another head version of your ruby, eg `rvm use jruby` used to point to 1.5.0 but now points to 1.5.2 so if you have a project setup to use 1.50, now you have to type `rvm use jruby-1.5.0` so if you setup an alias make sure you use the full ruby description or it may not find your gemset after updating.
Jed Schneider