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/LinuxI’m trying to upgrade the version of Ruby on my machine, which is currently installed at
/usr/lib/ruby/1.9.1I 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 2 Answers
Why not use ruby 2.3 which is available in the repositories for 16.04 and 17.10 with
sudo apt updateAfter the update is finished run:
sudo apt-get install ruby2.3 ruby2.3-devOr 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 updateinstall
sudo apt-get install ruby2.4or 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.
On Ubuntu 14.04 this worked for me to install ruby 2.4.1
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-devThen install rbenv
cd git clone git:// .rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile echo 'eval "$(rbenv init -)"' >> ~/.bash_profile git clone git:// ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profileNow install ruby 2.4.1
rbenv install -v 2.2.3To set 2.4.1 as a default use command rbenv global 2.4.1.