Install Ruby 1.9.2 (from source) and Rails 3.0.1 on Ubuntu 10.10

Post to Twitter

Although I believe using RVM is a better way to install and manage Ruby on Ubuntu (see my article on how to do that), you can however just install Ruby from source code. Today I’ll go over the steps to do that as well as installing Rails 3.0.1 and SQLite.


I will be installing Ruby 1.9.2 on a clean Ubuntu 10.10 system. The first thing is to install all the required libraries:

$ sudo apt-get update
$ sudo apt-get install build-essential zlib1g zlib1g-dev libreadline5 libreadline5-dev libssl-dev

Grab the source code from the Ruby FTP site and adjust the version number as newer builds are released into the stable tree:

$ mkdir ruby-src && cd ruby-src
$ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
$ tar -zxvf ruby-1.9.2-p0.tar.gz && cd ruby-1.9.2-p0
$ ./configure
$ make && sudo make install

Verify that the correct Ruby version is now running:

$ ruby -v

Expected output:

Since RubyGems already comes with Ruby 1.9.2 we can install Rails 3.0.1 (without the documentation) like this:

$ gem update --system
$ sudo gem install rails --no-rdoc --no-ri

Verify the correct Rails version was installed:

$ rails -v

Expected output:

Install SQLite and the SLQite ruby binding (without the documentation):

$ sudo apt-get install sqlite3 libsqlite3-dev
$ sudo gem install sqlite3-ruby --no-rdoc --no-ri

Verify the correct SQLite version was installed:

$ sqlite3 --version

Expected output:

List and verify your local Gems:

$ gem list --local

You are now ready to build Ruby on Rails 3 web apps.

Post to Twitter

This entry was posted in Open Source, Rails, Ruby, Ubuntu. Bookmark the permalink.

5 Responses to Install Ruby 1.9.2 (from source) and Rails 3.0.1 on Ubuntu 10.10

  1. Marcus says:

    Thanks for the article. I was looking for a good starter’s tutorial on how to install Ruby from source, and got to learn a couple other things as a bonus.

  2. Hi,

    I was wondering how did you know you have to install the following dependencies:

    “build-essential zlib1g zlib1g-dev libreadline5 libreadline5-dev libssl-dev”

    I understand why “build-essential”, “zlib1g-dev” and “libssl-dev” (I got errors in Rails after compiling Ruby without the last two), but why “libreadline”?

    Thanks in advance.

  3. Chad Lung says:

    @Felipe,

    One way to find this out is to go through the Ubuntu website to see what libraries packages are using and then use that information to get the dependent libraries when building from source: http://packages.ubuntu.com/maverick/libruby1.8
    (thats for Ruby 1.8.x)

    Sometimes libraries like libreadline can already be installed as well.

    Chad

  4. Ah, right! Thanks for the tip, Chad.

  5. Eshan says:

    But my Rails version is not updated. Its showing old version. I tried to install MySQL using following code:

    sudo apt-get install mysql-server mysql-client mysql-gui-tools-common libmysqlclient16 libmysqlclient16-dev

    and

    sudo gem install mysql

    But now I couldn’t check my rails version. If I tried to check rails version it showing following error.

    /usr/local/lib/ruby/1.9.1/rubygems.rb:762:in `report_activate_error’: Could not find RubyGem rails (>= 0) (Gem::LoadError)
    from /usr/local/lib/ruby/1.9.1/rubygems.rb:219:in `activate’
    from /usr/local/lib/ruby/1.9.1/rubygems.rb:1065:in `gem’
    from /usr/local/bin/rails:18:in `’

    please help me to solve this problem

Comments are closed.