Sonntag, 9. Dezember 2012

Rubies on RVM

Sometimes you are forced to switch your time-tested Ruby application to a newer Ruby version. You don't need to be scared. There is RVM, the Ruby Version Manager. It let you use different Rubies conveniently by just a simple command. You even can install several gemsets per Ruby version! It's easy to install:
user$ \curl | bash -s stable
Please notice the backslash before curl. This prevents misbehaving if you have aliased it with configuration in your ~/.curlrc file. Make sure your current terminal session has loaded RVM:
user$ source ~/.rvm/scripts/rvm
When you open a new shell, RVM is loaded automatically. Test if your installation was successful:
user$ type rvm | head -n 1
rvm is a function
Your terminal should output: rvm is a function Finally, see if there are any dependency requirements for your operating system by running:
user$ rvm requirements
Installation done. Let's play around with certain Rubies. First install one, e.g. Ruby 1.9.2:
user$ rvm install 1.9.2
Use the crisp Ruby installation:
user$ rvm use 1.9.2
Check the version of your current Ruby:
user$ ruby -v
If you want to know which Ruby versions you already got on your RVM, list them:
user$ rvm list known
Set your favourite Ruby as default:
user$ rvm use 1.9.2 --default
One huge benefit of RVM is the possibility to install several named gemsets independent from your installed Ruby.
Create a gemset for Rails 3.2.9 (on your default Ruby 1.9.2):
user$ rvm gemset create rails_329
Use it:
user$ rvm use 1.9.2-head@rails_329
Install you first gem (Rails 3.2.9) on you gemset:
user$ gem install rails -v 3.2.9
List the gemsets on your current choosen Ruby:
user$ rvm gemset list
There are a lot more options for RVM (e.g. user installation or benchmarking your code against several versions of Ruby and many more). I just referred to only a few/ some of the most important.
For going into detail please visit the RVM page. There you also will find an answer, if you discovered an issue depending on your used OS. Anyway you should take a look.

Keine Kommentare:

Kommentar veröffentlichen