Ruby Alternatives for Ubuntu 11.04 and 11.10

alternativeruby

Running update-alternatives --config ruby fails:

# uname -a
Linux test06 2.6.38-8-virtual #42-Ubuntu SMP Mon Apr 11 04:06:34 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.04
DISTRIB_CODENAME=natty
DISTRIB_DESCRIPTION="Ubuntu 11.04"

# apt-get install ruby1.9.1-full
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ruby1.9.1-full is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 25 not upgraded.

# update-alternatives --config ruby
update-alternatives: error: no alternatives for ruby.

# ls -l /etc/alternatives/ru*
ls: cannot access /etc/alternatives/ru*: No such file or directory

2 days ago (January 15th, 2012) I wrote a Puppet manifest that used update-alternatives to setup the correct Ruby version. Today, update-alternatives fails as described above. Where did the Ruby alternatives go?

Best Answer

Well you need more than 1 version of ruby installed for there to possibly be an alternative to "ruby" (generally /usr/bin/ruby

If you only have ruby1.9.1 installed, (ruby1.9.X), then there is no alt. available

Ex. here on 11.10, - for some media apps I need both 1.9.2 & 1.8 installed so update-alternatives reflects that & allows me to switch as needed

$ sudo update-alternatives --config ruby
[sudo] password for doug: 
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).

Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/ruby1.8     50        auto mode
  1            /usr/bin/ruby1.8     50        manual mode
* 2            /usr/bin/ruby1.9.1   10        manual mode

Press enter to keep the current choice[*], or type selection number: 

By default in 11.04/11.10 the package "ruby" provides ruby1.8

Related Question