Installing ruby is easy enough using apt-get install ruby1.9.1.

But how can I set it as the default/system/global ruby in a automated fashion?


Simply make sure that the ruby found in $PATH is (a link to) the right one.

On my Ubuntu 12.04 (if I disable rvm, which I'm normally using to manage rubies),

which ruby

shows /usr/bin/ruby and ls -l which ruby reveals that it's a link to /etc/alternatives/ruby which is again a link, whose destination is intended to be managed by the update-alternatives command.

So I can either use update-alternatives to point it to the right version (probably the preferred way to do it), create the link manually, or make sure the $PATH variable ends up at a different link (perhaps one placed in $HOME/bin ) that points to the right ruby. (Note: the actually binaries on my system are installed in /usr/bin and are distinguished by having their version in their name, e.g. /usr/bin/ruby1.9.3).

All of these instructions are bash commands (or references to bash commands) so automation should be just about putting those commands in a script.

  • I'm on a fresh install of Ubuntu 12.04.2 LTS, and me doing which ruby returns nothing, The program 'ruby' can be found in the following packages: * ruby1.8 * ruby1.9.1 Try: sudo apt-get install <selected package> So I'm looking a way to automate this in a script somehow. – Blankman Feb 25 '13 at 1:39
  • Try making a link to it. ruby1.9.1 should work so all you need to do is make an alias or link named ruby that will run ruby1.9.1, which is by default in /usr/bin/. – PSkocik Feb 25 '13 at 10:53
  • You can do it with sudo ln -s /usr/bin/ruby{1.9.1,}; sudo ln -s /usr/bin/irb{1.9.1,}. – PSkocik Feb 25 '13 at 10:57

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.