$ sudo apt-get build-dep ruby1.8 ruby1.9
Create a directory for the Ruby source code.
$ mkdir /home/ryan/source
$ cd /home/ryan/source
Check out the code from the 1.8 branch. Since this branch includes patches, you can always update your source and recompile when new patches are released.
$ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 ruby1.8
Next, create a configuration, configure, and compile.
$ cd ruby1.8
$ autoconf
$ ./configure --prefix=/opt/ruby1.8 --program-suffix=1.8
$ sudo make
$ sudo make install
Finally, link your new binaries to the /usr/local/bin directory.
$ sudo ln -s /opt/ruby1.8/bin/* /usr/local/bin
Typing ruby1.8 -v in a new console should yield something similar to the following:
$ ruby1.8 -v
ruby 1.8.7 (2008-09-15 revision 19348) [i686-linux]
One of the best parts of Ruby is Rubygems! Download and install it.
$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
$ tar -xvzf rubygems-1.2.0.tgz
$ cd rubygems-1.2.0
$ sudo ruby1.8 setup.rb
The current source for Ruby 1.9 requires version 1.8 to compile, but if you’ve followed my directions up to this point you should be ready to download and compile the latest Ruby 1.9 source code.
Go back to your source directory and check out the latest code from the 1.9 trunk.
$ cd /home/ryan/source
$ svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby1.9
$ cd ruby1.9
This time use the –with-baseruby switch when configuring. Set this option to the new Ruby 1.8 binary and then compile.
$ autoconf
$ ./configure --with-baseruby=/usr/local/bin/ruby1.8 --prefix=/opt/ruby1.9 --program-suffix=1.9
$ sudo make
$ sudo make install
Finish by linking your new Ruby 1.9 binaries to /usr/local/bin.
$ sudo ln -s /opt/ruby1.9/bin/* /usr/local/bin
Typing ruby1.9 -v in your console should yield something similar to the following:
$ ruby1.9 -v
ruby 1.9.0 (2008-09-15 revision 19351) [i686-linux]
Ruby 1.9 includes Rubygems! We’re done!