Today: July 5th, 2008

Upgrading Ruby in Ubuntu Without Using Apt

For some reason I need to upgrade the installed Ruby versions in my development PC and in slicehost VPS. Both uses Ubuntu: dev has ubuntu edgy, VPS has ubuntu dapper. Ruby is already in version 1.8.6 while the one in Ubuntu repository through apt-get is stuck at 1.8.4. So I upgraded by compiling Ruby source files.

Here's what I did:

CODE:
  1. sudo apt-get install build-essential
  2. sudo apt-get install libreadline5 libreadline5-dev
  3. wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
  4. tar -xzf ruby-1.8.6.tar.gz
  5. cd ruby-1.8.6
  6. ./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local
  7. make
  8. sudo make install

After compiling, Ruby will be installed in /usr/local directories. Run 'ruby -v' and check if it say 'ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]'.

CODE:
  1. wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
  2. tar -xzf rubygems-0.9.4.tgz
  3. cd rubygems-0.9.4
  4. sudo ruby setup.rb

You might need to reinstall your gems. I'm using Rails so when I tried running 'script/console', I get something like:

CODE:
  1. /usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require':
  2.   no such file to load -- readline (LoadError)
  3.     from /usr/local/lib/ruby/1.8/irb/completion.rb:10
  4.     from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
  5.     from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
  6.     from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'
  7.     from /usr/local/lib/ruby/1.8/irb.rb:54:in `start'
  8.     from /usr/local/bin/irb:13

Weird because when I logged out and in again, the problem went away.

comments

Leave a Reply