Setting up ruby on rails on ubuntu

First of all, I am following on-line version of rails tutorial ( Michael recommends sublime text 2 as editor. I use textmate on my mac, but I wouldn’t have the luxury of mac at work, so I am giving a try.

open a terminal here

Since I comes from windows background, I don’t like navigating in terminal. This util will install a menu on nautilus file browser

$ sudo apt-get install nautilus-open-terminal

sublime text

You can download sublime text 2. I did and it is now in download folder. Ah, I don’t know how to install application ubuntu. Do I have to run setup file like windows or drag and drop to application folder like mac? Sublime forum says I can create an “apps” folder in /home/{user}/ and put it there. Luckily, the text seems to be a stand-alone files, so I copied the directory to /home/andrew/apps/.

install Git

The free chapter of Pro Git is very helpful. I simply did

$ sudo apt-get install git-core

Install Ruby

I did $ruby -v, and it has ruby 1.9.1. It should be all right, but I want to use the latest available. Michael recommends installing ruby by using RVM, so I will go for it.

I will use “aptitude”, following the instruction. To find out if you have “aptitude”, you can do

$ sudo aptitude

If you get an error then, you need to install it by doing the below.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install aptitude

Let’s install git core and curl

$ sudo aptitude install build-essential git-core curl

Then install RVM. This helps you manage multiple versions of ruby.

bash -s stable < <(curl -s )

This is a kind of weird command to me, a ubuntu beginner, but it seems to work. Once RVM is installed, you need to load it to terminal. By adding the following command, you can make it be loaded automatically each time you start bash shell.

$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc

Check if it is successfully installed. You may have to close your current terminal session and open again to load RVM. type

$ rvm notes

You should see the note if it is installed.

Now install several helpful ruby packages.

$ sudo aptitude install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev zlib libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison

Finally, you are ready to install ruby. So far, all packages were for ruby, not ruby.

$ rvm get head && rvm reload
$ rvm install 1.9.3

Install Rails

use gem to install rails. I had to use “sudo” due to permission issue on my ubuntu.

$ gem install rails -v 3.2.3
$ sudo apt-get install libxslt-dev libxml2-dev libsqlite3-dev

Check the version by doing $ rails -v.

After I install rails in this way, I get an error saying “invalid gemspec invalid date format” It seems Ubuntu prefers installing rails through apt-get install gem

$ apt-get install gem

Please let me know if anything does not work in this post.

Afterward …


It is quite frustrating that you go through quite a few errors. It makes me miss windows’ simple msi installer!

“Could not find railties” error. For some reason, railties are not installed.

$ sudo gem install railties

“Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
An error occured while installing rack (1.4.1), and Bundler cannot continue.
Make sure that `gem install rack -v ‘1.4.1’` succeeds before bundling.”

This one is self-explanatory, I think. Just install rack.

$ sudo gem install rack -v 1.4.1

ruby version problem.
I kept losing RVM whenever I start a new terminal session. Put this settings to your bash config

$ gedit .bashrc

Then put this at the end of the file.
[[ -s “$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm” # This loads RVM into a shell session.

Then RVM will be loaded automatically, and you will have the same version of ruby each time.

not function. ‘rvm use …’ will not work
If you run rvm use on ubuntu terminal, you get this message. It is because your bash shell is not login shell by default. Open the terminal settings and integrate rvm with gnome terminal.

Setting up ruby on rails on ubuntu

Leave a Reply

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

You are commenting using your 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