How do I upgrade to Ruby 2.2 on my Ubuntu system?
I’m using Ubuntu Linux. Below is the uname info
myuser@myinstance:~$ uname -a
Linux myinstance 3.18.0-52-generic #123-Ubuntu SMP Fri Feb 19 14:27:58 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
I’m trying to upgrade the version of Ruby on my machine, which is currently installed at
/usr/lib/ruby/1.9.1
I tried following the advice here — Install ruby 2.2.3 via apt, but unfortunately I get the error, “alternative path /usr/bin/ruby2.2 doesn't exist”. What is the right way to upgrade my system to use Ruby 2.2 or greater?
myuser@myinstance:~/racertracks$ sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby2.2 400 \
> --slave /usr/bin/rake rake /usr/bin/rake2.2 \
> --slave /usr/bin/ri ri /usr/bin/ri2.2 \
> --slave /usr/bin/rdoc rdoc /usr/bin/rdoc2.2 \
> --slave /usr/bin/gem gem /usr/bin/gem2.2 \
> --slave /usr/bin/irb irb /usr/bin/irb2.2 \
> --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby2.2.1.gz \
> --slave /usr/share/man/man1/rake.1.gz rake.1.gz /usr/share/man/man1/rake2.2.1.gz \
> --slave /usr/share/man/man1/ri.1.gz ri.1.gz /usr/share/man/man1/ri2.2.1.gz \
> --slave /usr/share/man/man1/rdoc.1.gz rdoc.1.gz /usr/share/man/man1/rdoc2.2.1.gz \
> --slave /usr/share/man/man1/gem.1.gz gem.1.gz /usr/share/man/man1/gem2.2.1.gz \
> --slave /usr/share/man/man1/irb.1.gz irb.1.gz /usr/share/man/man1/irb2.2.1.gz
update-alternatives: error: alternative path /usr/bin/ruby2.2 doesn't exist
Solution 1:
Why not use ruby 2.3 which is available in the repositories for 16.04 and 17.10 with
sudo apt update
After the update is finished run:
sudo apt-get install ruby2.3 ruby2.3-dev
Or try ruby 2.4 or 2.5
You can get those via the brightbox PPA
-
Add the repository and update
sudo apt-add-repository ppa:brightbox/ruby-ng && sudo apt-get update
-
install
sudo apt-get install ruby2.4
or for 18.04
sudo apt-get install ruby2.5 ruby2.5-dev
Information on the status of packages in the aforementioned PPA can be found on the “Brightbox” team launchpad page.
Alternatively you could try reverse hacking the error alternative path /usr/bin/ruby2.2 doesn't exist
by creating it with sudo mkdir /usr/bin/ruby2.2
and trying again.