Getting started with rvm and Rails
07 Jan 2011
Knowledge
We'll show a quick step-by-step to getting started with rvm on a new Rails application setup (in Ubuntu 10.04).
Install rvm
You'll need Git and cURL
$ sudo apt-get install git-core curlnow cd to your home directory and install rvm from there
$ bash < <( curl https://rvm.beginrescueend.com/releases/rvm-install-head )then add this to your ~/.bash_profile, at the end of the file
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"test rvm installation
$ type rvm | head -1if everything so far goes well, you should see
rvm is a functionInstall rubies Before installing any of the Rubies, you want to install the required libraries first
$ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-devnow let's have ruby 1.8.7 as our first addition the our rubies
$ rvm install 1.8.7then activate ruby 1.8.7 as our default
$ rvm --default use 1.8.7test your installation with
$ ruby -vyou should see
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-linux]now let's add ruby 1.9.2
$ rvm install 1.9.2use and test 1.9.2 installation like we tested 1.8.7 Using .rvmrc Now let's create a directory that will hold your Rails app and create .rvmrc file there
$ mkdir awesomeapp $ echo "rvm 1.9.2@awesomeapp" > awesomeapp/.rvmrc $ cd awesomeappanswer the question with 'y' and create the gemset and reload rvm
$ rvm gemset create 'awesomeapp' $ rvm reloadthen
$ gem env gemdirshould give you
/home/username/.rvm/gems/ruby-1.9.2-p136@awesomeappCreate a Rails application From your 'awesomeapp' directory
$ gem install rails $ rails new . $ bundle installTest your Rails app
$ rails serverand go to http://localhost:3000/ on your browser. If you see Rails default home page then you are good to go to code your next awesome Rails app. Summary Using rvm you can work with many rubies. You can work on one app using ruby 1.8.7 and another app with 1.9.2 also test your ready to deploy application using ree. By creating .rvmrc file in every project directory you can manage your gem installation easier. No more gem conflict between app.
