1

I have Ruby 2.0.0 installed on Ununtu 14.04 but I can't remove Ruby 1.9.1. I replaced the /usr/bin/ruby symbolic link to ruby2.0.0, but hhen installing new gems I always get pointed to Ruby 1.9.1.

How can I definitely switch to Ruby 2.0.0?

  • sudo apt-get purge ruby ruby1.9.1. Note that 1.9.1 is still the default, and there may be programs using this version. – saiarcot895 May 25 '14 at 0:51
  • 1
    ruby2.0 is removed too: The following packages will be REMOVED: libruby1.9.1* libruby2.0* ruby* ruby1.9.1* ruby2.0* rubygems-integration* – Rafael Borja May 25 '14 at 0:56
  • Well, that's a wrench I didn't see coming. – saiarcot895 May 25 '14 at 1:12
5

For Ruby, the basic dependency structure goes like this:

  1. ruby (which would ideally be a metapackage that points to the default version) depends on ruby1.9.1
  2. ruby2.0 depends on ruby

I'm not sure why they did this, or why they removed the ability to use alternatives here, but if you want to force the use of Ruby 2.0, then one non-invasive way to do this is to create symlinks to the 2.0 binaries. The snippet below will create symlinks in /usr/local/bin.

for i in erb gem irb rdoc ri ruby testrb; do
    sudo ln -s /usr/bin/$i''2.0 /usr/local/bin/$i
done

Ruby 1.9.1 is still accessible by appending 1.9.1 to the binary name (for example, gem1.9.1).

  • Thank's! I created a symlink but I had problems with gem. Now it works! Thanks! – Rafael Borja May 25 '14 at 1:25
1

As an alternative to hand-maintaining multiple symlinks, I suggest using update-alternatives. In another question, I provided a script to handle all binaries and man pages in ruby versions 1.9.1 and 2.0 (as currently found in my 14.04 system), though the script is easily extended to different versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.