Ruby – How to Uninstall Ruby 1.8.7 and Install Ruby 1.9.2

ruby

Does anyone know how to properly uninstall Ruby 1.8.7 and install Ruby 1.9.2 on Ubuntu 11.10?

I have thoroughly searched and none of the tutorials I've found have worked.

Also, I spent a very long time trying to get RVM to work and it just is a pain to use. Additionally, I will have little use for the older version.

Update outputs:

which ruby:

/usr/local/bin/ruby

ls -l /usr/local/bin/ruby:

lrwxrwxrwx 1 root root 16 2011-10-17 21:20 /usr/local/bin/ruby -> /usr/bin/ruby1.8

ls -l /etc/alternatives/ruby:

lrwxrwxrwx 1 root root 18 2011-12-30 17:35 /etc/alternatives/ruby -> /usr/bin/ruby1.9.1

echo $PATH:

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

By the way, when I look at –config gem, it tells me that there is only one gem, which is /usr/bin/gem1.9.1

Best Answer

Is there a problem with having both installed? And using the versions from the repositories? I would install ruby 1.9.2 with:

sudo apt-get install ruby1.9.1-full

And then update the "alternatives" system to use ruby 1.9:

$ sudo update-alternatives --config ruby
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: 2
update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in manual mode.
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

This will also set the alternatives for erb, irb, rdoc, ri, testrb and the man page. However you need to update the gem command separately:

$ sudo update-alternatives --config gem
There are 2 choices for the alternative gem (providing /usr/bin/gem).

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

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/gem1.9.1 to provide /usr/bin/gem (gem) in manual mode.

I know, it is confusingly called ruby1.9.1 rather than 1.9.2, some upstream debian packaging thing.

Related Question