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:
-
sudo apt-get install build-essential
-
sudo apt-get install libreadline5 libreadline5-dev
-
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
-
tar -xzf ruby-1.8.6.tar.gz
-
cd ruby-1.8.6
-
./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local
-
make
-
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:
-
wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
-
tar -xzf rubygems-0.9.4.tgz
-
cd rubygems-0.9.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:
-
/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
Weird because when I logged out and in again, the problem went away.