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?
For Ruby, the basic dependency structure goes like this:
ruby
(which would ideally be a metapackage that points to the default version) depends on ruby1.9.1
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
).
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.
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.