ruby

Install Ruby 1.9.2 and Rails 3 on Ubuntu 11.04

It seems apt-get hasn’t updated with ruby 1.9.2 and rails 3, so apt-get install ruby/rails won’t get ruby 1.9.2 and rails 3 (at least not for me at the moment).
But I really want to explore the world of rails 3, especially I’ve heard a lot has been changed since rails 2, which was the version last time I touched it while I was at CMU.
I was going to build from source but luckily I found this blog post which saved me quite a bit of time and effort.
However, I did encounter some problems by following the steps from that post, so I’m posting my steps here hopefully this could be useful to some else.

first you need to install bunch of packages via apt-get if you haven’t already:

1
apt-get install curl git-core build-essential bison openssl libreadline5 libreadline5-dev zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev mysql-client mysql-server autoconf

then you need install rvm, which is a great tool to manage your ruby version (I guess it’s like python_select in ruby world)

1
curl -s https://rvm.beginrescueend.com/install/rvm

add the following line to your .bashrc

1
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

source it so rvm is available in your shell session, I think the original post didn’t mention this step so if you follow it strictly like I did you will get an error like svmsudo command not found in further steps.

1
source ~/.rvm/scripts/rvm

then install ruby and rails

1
2
3
4
5
6
7
8
rvm install 1.9.2
rvm use 1.9.2 --default
rvm 1.9.2 --passenger
rvm 1.9.2
gem install passenger
apt-get install libcurl4-openssl-dev
rvmsudo passenger-install-nginx-module
gem install rails

you should be able to use rails now:

shiqi@ubuntu:~$ which ruby
/home/shiqi/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
shiqi@ubuntu:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
shiqi@ubuntu:~$ which rails
/home/shiqi/.rvm/gems/ruby-1.9.2-p180/bin/rails
shiqi@ubuntu:~$ rails -v
Rails 3.0.8

easy, huh?

kudos to the author of the following references:
1. http://stuffingabout.blogspot.com/2011/04/installing-rails-3-on-ubuntu-1104.html
2. http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/
3. https://rvm.beginrescueend.com/rvm/install/

EmailDiggFacebookDeliciousStumbleUponTwitterTumblrGoogle GmailBlogger PostGoogle ReaderSina WeiboBox.netEvernoteFriendFeedGoogle BookmarksHotmailLiveJournalLinkedInPrintPrintFriendlyRedditSlashdotWordPressShare

Tags: , , , ,

Friday, June 10th, 2011 linux, rails, ruby, ubuntu No Comments