Installing Ruby 1.9.2 on Ubuntu 11.10 Oneiric Ocelot without using RVM
It seems installing Ruby 1.9 on Ubuntu without the use of RVM isn’t all that trivial. I had to poke around the system for quite a while before I got it running.
Why not RVM?
Well, I tried RVM but compiling Ruby took 3 hours on my EC2 micro instance and was eating all my CPU so that my webserver was basically not available anymore. To me that isn’t acceptable. Besides, I think it is highly wasteful to compile packages from source when there are precompiled versions available. I admit that apt is too slow to keep up with the rapidly moving gems ecosystem but for the Ruby interpreter itself I strongly prefer the OS to handle the installation.
Besides I don’t really want to use different versions of Ruby at the same time. I just want something that isn’t Ubuntu’s default 1.8.7, which in Ruby years is ancient.
The steps
The good news is that as of writing this, Ruby 1.9.2 is available without any PPAs straight from the official Canonical package repos. The bad news is that information about how to get it is thin on the ground.
For starters the package for Ruby 1.9.2 is called ruby1.9.1 and Googling around, it wasn’t immediately obvious that any version of Ruby 1.9 is even possible on Ubuntu.
Anyway, here it goes:
This installs Ruby 1.9.2 and sets that to be the default ruby on your system. Crucially, it also installs rubygems for that interpreter and sets that to be the default. (Thanks for the initial snippet to Michał Frąckowiak. His version got me most of the way there.)
Uninstalling Ruby 1.8
If you, like me, ran a Rails app on 1.8 you probably have a bit of stuff hanging around the file system. Lets clean that up.
First uninstall all gems from the 1.8 installation with:
Secondly, remove the ruby packages with apt.
After you have done that you may want to check if there is anything else hanging around with a quick: