How to install Ruby 2.2.3 via apt on Ubuntu Wily? I tried sudo apt-get install ruby2.2-dev and sudo apt-get install ruby2.2 (What's the difference, btw) and both commands seem to have installed quite a bunch. However, there's no ruby executable afterwards.
- 453
- 1
- 4
- 10
-
do you absolutely install want to install ruby 2.2.3 via apt ? The *-dev package contains headers and files that * may need to function correctly. check the official https://www.ruby-lang.org it contains the information you need to install ruby 2.2.3 correctly – enzo Oct 28 '15 at 16:46
-
please refer if it is useful [https://gorails.com/setup/ubuntu/15.10] – Ravan Oct 28 '15 at 17:04
-
1@maetsoh Why would I install every single package with apt, _except_ ruby? I like package managers. – Michiel de Mare Oct 29 '15 at 06:48
-
Is Ruby part of the "alternatives" mechanism on Ubuntu? If not, it might be worthwhile using something like [rbenv](https://github.com/sstephenson/rbenv) to manage Ruby installs. Especially if you need to use different versions of Ruby at the same time. Soft-linking can get a little tiresome when doing Rails development, etc. – Oct 29 '15 at 14:33
-
I use rbenv locally for switching versions, so it's worth the hassle.But on production I only need 1 ruby version, and then I prefer the standard package manager. I'll read up on the "alternatives" mechanism. (http://manpages.ubuntu.com/manpages/vivid/en/man8/update-alternatives.8.html) – Michiel de Mare Oct 29 '15 at 16:34
2 Answers
Ok, this worked for me on vivid at least:
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.2 ruby2.2-dev
On wily, I get an error because the URL http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu/dists/wily/main/binary-amd64/ is missing, there's only http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu/dists/devel/main/binary-amd64/.
- 3,306
- 10
- 26
- 37
- 453
- 1
- 4
- 10
apt-get install ruby2.2 does give you a ruby executable - it's just called ruby2.2. Gem and irb are the same (i.e. gem2.2 install bundler will work, irb2.2 will give you an irb prompt.)
This is normal in Ubuntu and the alternatives system generally means you don't have to care about it, but for whatever reason ruby isn't managed by alternatives in Ubuntu. But we can make it:
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
Running this will register ruby with the alternatives system and, as there's only one choice, set ruby 2.2 as default. This will create symlinks and let you use ruby/gem/ etc. without adding 2.2 on the end.
This is a slightly updated version of instructions found at https://leonard.io/blog/2012/05/installing-ruby-1-9-3-on-ubuntu-12-04-precise-pengolin/
- 96
- 1
-
update-alternatives: error: alternative gem can't be slave of ruby: it is a master alternative – Yevgen Kulik May 30 '16 at 09:15