PPA Updates for Ruby 1.9.1 and Ruby 1.9.2 – Handling Ruby Versions using the update-alternatives system

I recently created PPAs for Ruby 1.9.1 and Ruby 1.9.2. The default Ruby 1.9.1 package creates binaries in /usr/bin with names like ruby1.9.1, irb1.9.1 etc. However a lot of scripts depend on /usr/bin/ruby and /usr/bin/irb which are provided by Ruby1.8. Hence when I created the PPA for ruby1.9.1, I hardcoded the symlinks – /usr/bin/ruby1.9.2 => /usr/bin/ruby etc.

However Antoniosuggested that I should use the update-alternatives system instead. I knew that was the way to go, but didn’t read up about it when I was creating the PPAs and used the symlinks instead. I took his suggestion and updated the Ruby1.9.1 and Ruby1.9.2 packages to support the update-alternatives system. However I soon realized that the Ruby1.8 package still uses hard-coded symlinks. So I ended up updating the Ruby-Defaults package too so that Ruby1.8 would support the update-alternatives system. Ruby1.9.2 has the highest priority and hence will be selected by default. Choose your desired Ruby Version using the following command.

sudo update-alternatives --config ruby

If you have installed rdoc, ri, irb etc, make sure that you update their version too to match the ruby version you are using.