Rod McLaughlin


How to use RVM (10 nov 12)

RVM (Ruby Version Manager) is a Godsend to all Ruby developers.

It was created by Wayne Seguin - it is available at https://rvm.io/

The best way to use it is to create a new gemset for every one of your Ruby projects.

$ cd ~/subcryption
$ rvm use 1.9.3-p125
$ rvm gemset create 'subcryption' 
$ rvm --rvmrc --create use ruby-1.9.3-p125@subcryption
$ gem list | cut -d" " -f1 | xargs gem uninstall -aIx
$ gem install --no-ri --no-rdoc bundler
$ bundle install # Assuming subcryption has a Gemfile - 'gem install EACH_GEM' if not

This creates a .rvmrc file in the top-level folder for each of these projects. A typical .rvmrc file looks like this:

environment_id="ruby-1.9.3-p125@subcryption"

When you cd into folder 'subcryption', RVM uses the Ruby and the gems bundled together as "ruby-1.9.3-p125@subcryption" (a version of Ruby, plus a 'gemset') automatically.


It is best to check these RVM 'gemsets' in to source control. When a developer works on project X, with Ruby version N, patch P, he uses gemset ruby-N-P@X. When he changes the gemset, he checks it in. That way, every developer is using the same Ruby, and the same gems, per project. Otherwise, just because it works on your machine, doesn't mean it'll work on anyone else's.

 



Back
Portland London