Posts Tagged ‘Rails2’

Ruby 1.9.1 with rvm

November 17, 2009

Since both planned applications will be using Ruby 1.9.1 and for my everyday’s work I have 1.8.7 installed, the best solution would be to use rvm to easy switch between versions. The rvm documentation is pretty straightforward, so let’s just get started:

~/projects[]$ sudo gem install rvm
Successfully installed rvm-0.0.78
1 gem installed
~/projects[]$ rvm-install
~/projects[]$ source ../.rvm/bin/rvm
~/projects[]$ rvm install 1.9.1
...
<i> Extracting ruby-1.9.1-p243 ... </i>  
<i> Configuring ruby-1.9.1-p243, this may take a while depending on your cpu(s)... </i>  
<i> Compiling ruby-1.9.1-p243, this may take a while, depending on your cpu(s)... </i>  
<i> Installing ruby-1.9.1-p243 </i>  
<i> Installation of ruby-1.9.1-p243 is complete. </i>  
<i> Updating rubygems for ruby-1.9.1-p243 </i>  
<i> Installing gems for ruby-1.9.1-p243. </i>  
<i> Installing rake </i>  
<i> Installation of gems for ruby-1.9.1-p243 is complete. </i>

The good thing about rvm is it installs the desired Ruby version from source. It also keeps separate gem repositories.

From now on we can do rvm use to switch between system version (1.8.7) and 1.9.1:

~/projects[]$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
~/projects[]$ gem list

*** LOCAL GEMS ***

<VERY LONG LIST HERE>
~/projects[]$ rvm use 1.9.1
<i> Now using ruby 1.9.1 p243 </i>
~/projects[]$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
~/projects[]$ gem list

*** LOCAL GEMS ***

rake (0.8.7)
rubygems-update (1.3.5)

~/projects[]$ rvm use default
no default rvm specified, defaulting to pre-rvm system.
~/projects[]$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]

So, Ruby 1.9 is ready to use. It is worth to mention, that, if you use more sophisticated IDEs like Netbeans or RubyMine, it is better to start them from the same console, where you have just rvm-switched to your working Ruby version – at least at the first time, for project setup.