Installing Rails (with readline and console support) on Ubuntu LTS

Here's what I had to do to get Ruby on Rails to run on Ubuntu LTS with a functioning console (and irb).

It comes down to:

  1. Random packages
  2. Ruby (from source)
  3. Mysql packages
  4. Rubygems (from source)
  5. Rails (from a gem)

Building on posts by:

Thanks guys.

Preliminaries

Mostly via Ed Howland's post (I believe termcap-compat, which he lists, is no longer necessary, since libc is up to 6 or uh erm... well I don't rightly know, but that package wasn't in the repos and everything seems to work for me without it! ☻).

sudo apt-get install gcc
sudo apt-get install build-essential
sudo apt-get install bison byacc gperf
sudo apt-get install zlib1g-dev
sudo apt-get install libreadline5 libreadline5-dev
sudo apt-get install libncurses5 libncurses5-dev 
sudo apt-get install libssl-dev

Build Ruby

Download the Ruby source:

wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5-p12.tar.gz
tar xzf ruby-1.8.5-p12.tar.gz

And build it. Make some coffee, this takes a while. ☻

cd ruby-1.8.5-p12
./configure
make
sudo make install

Not sure why this is necessary (ActionMailer?)

apt-get install postfix

You'll also want Ruby's documentation stuff:

sudo apt-get install  rdoc ri irb

Mysql packages

apt-get install mysql-server mysql-common mysql-client
apt-get libmysqlclient15-dev libmysqlclient15off
apt-get install libmysql-ruby1.8

Build Ruby Gems

We'll be using this to install Rails:

wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
tar xzf rubygems-0.9.0.tgz
cd rubygems-0.9.0
sudo ruby setup.rb

Build Rails

Actually the easiest part, I've never had trouble with this (knock wood).

sudo gem install rails --include-dependencies
sudo gem install mysql

Note that the mysql gem is really the DB connector for Ruby; it's not Mysql itself. (We already did that.)

Afterword

Now that I've explained what worked for me, let me explain the problem I had, in case you're interested or facing the same problem.

When I originally followed the steops in Richard Crowley's post, everything seemed to install fine and Rails worked great.

But I found that my console wouldn't work, just like Paul Ingles:

Loading development environment.
      /usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require':
      no such file to load -- readline (LoadError)
        from /usr/local/lib/ruby/1.8/irb/completion.rb:10
        from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
        from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
        from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'
        from /usr/local/lib/ruby/1.8/irb.rb:54:in `start'
        from /usr/local/bin/irb:13

This means no readline in irb, and no script/console whatsoever, which I gotta have.

So I tried his solution, which consisted of building readline from source, and then building Ruby. I'm not totally positive (though I'm going to find out soon when I rerun this whole process on my laptop), but I think that the steps I've described above obviate building readline from source on Ubuntu.

And now this works! \o/

./script/console

Leave a comment!

I'd really appreciate comments about this process, especially corrections or simplifications.

I'd also just like to get in touch with other folks running Rails on Ubuntu! Believe it or not not everybody using Rails is on OSX. ;-)

The original version of this post is from my blog:

infundibulum » Blog Archive » Installing Rails (with readline and console support) on Ubuntu LTS