RSS

Installing RVM for Rails 3 in Ubuntu

15 Apr

RVM means Ruby Version Manager, which is used to install and switch over multiple ruby versions with just one line command and enables us to return back to default settings any time. Now let us see how to install RVM in ubuntu and then use that to install and use ruby1.9.2 – Rails 3. First open terminal and execute this one line command,

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

When it is finished, check your home folder to see .rvm folder which indicates that it is successfully  installed. Place the following line in your .bashrc file

[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm”

It is time to restart the system, and then execute,

rvm update –head
rvm reload

And for your notice, just forget sudo from now. Because once rvm is installed, all the version management you are going to do is user specific and switching over also user specific, and hence avoid using sudo which will clear out your environment while running as root user.

Now we are ready to install rails 3 for which ruby 1.9.2 is installed using

rvm install 1.9.2

Once this is done, rvm will create a new independent gem directory for this ruby version under .rvm folder. All the gems you install hereafter will be installed to that directory rather than the usual system directory ( the key factor for version switch over).

And it is also possible to create our own gemsets with the same ruby version so that we can have different version of gems packed as separate directories which can be as it is included for any project needed with one type. If i want to create a separate gemset for my project called demoproject, i can very well create by

rvm –create use 1.9.2@samplerails

This will create a new gemset directory under .rvm and orders to use that henceforth. Now all the gems you install will be placed under this directory. The next time you log in, you can simple order to use this gemset by

rvm use 1.9.2@samplerails ( to use already created gemset ), or

rvm –default use 1.9.2@samplerails ( to make this default if not specified ).

Now install rails 3 with

gem install rails –version 3.0.1

You are done!

And it may be necessary to initiate rvm every time you log on, if it is not loaded automatically. This can be done with,

[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm”



 
Leave a comment

Posted by on April 15, 2011 in RVM, Ubuntu

 

Tags: , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: