57

Is there any way, on Ubuntu 9.04, to install Ruby 1.8 as ruby1.8 (or get rid of it altogether) and have Ruby 1.9 be the default ruby?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Martin DeMello
  • 11,876
  • 7
  • 49
  • 64

5 Answers5

107

I'm not really sure, but maybe this can help:

update-alternatives --config ruby

... and here's the non-interactive, scriptable, way:

update-alternatives --set ruby /usr/bin/ruby1.9.1

You may find out about available alternatives and respective /usr/bin/... paths by doing:

update-alternatives --query ruby
Pavel Repin
  • 30,663
  • 1
  • 34
  • 41
just_a_dude
  • 2,745
  • 2
  • 26
  • 30
  • 3
    thanks, didn't work out of the box but searching for `update-alternatives ruby` brought up http://krnjevic.com/wp/?p=209 which has a howto – Martin DeMello Dec 12 '09 at 09:54
  • 1
    The correct way of dealing with this is to use RVM, as linked by henry74. Messing with Ubuntu directly is strongly discouraged, as it will increase your headaches later. – Amin Ariana May 21 '12 at 21:37
  • 14
    Using RVM isn't the "correct way", it's "a way". Installing a local Ruby in `/usr/local/bin` is the standard way, with an adjustment to the path to search `/usr/local/bin` before `/usr/bin` – the Tin Man Jun 04 '12 at 05:08
  • 5
    Also important to switch your gem version: `sudo update-alternatives --set gem /usr/bin/gem1.9.1` – richardkmiller Jan 28 '14 at 07:23
  • 2
    `update-alternatives` shows "no alternative for ruby"? – xji Dec 31 '15 at 08:18
  • @richardkmiller: even better, set the gem version as `--slave` of the ruby version, as shown in the blog post. – GhostLyrics Aug 09 '17 at 12:24
6

Martin - Take a look at the following link: http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

This is where installation of ruby is heading for ubuntu servers. This should allow you to not only switch to a ruby version when needed, but also keep gems separated based on ruby versions, etc.

derekerdmann
  • 17,696
  • 11
  • 76
  • 110
henry74
  • 1,015
  • 1
  • 10
  • 14
3

You can completely remove Ruby 1.8 too with:

sudo apt-get remove libruby1.8 ruby1.8 ruby1.8-dev rubygems1.8

After that, you will only have Ruby 1.9 installed.

Travis Reeder
  • 38,611
  • 12
  • 87
  • 87
2
sudo \curl -L https://get.rvm.io | bash -s stable --ruby --rails

will install an up-to-date version of ruby (and rails), and allow you to avoid brokenness of Ubuntu's RVM, see https://stackoverflow.com/a/9056395/497756.

If you go this route, get rid of Ubuntu-installed versions and associated packages like bundle.

Details here: https://rvm.io/rvm/install/

(Note: this is the TL;DR version of the post by henry74.)

Community
  • 1
  • 1
Joe Corneli
  • 642
  • 1
  • 6
  • 18
  • oh yeah, i definitely installed it myself. every time i've tried to install language-specific package managers via the system package manager, either on arch or on ubuntu, i've ended up regretting it. – Martin DeMello Jan 28 '13 at 05:17
-2

Try this:

sudo apt-get install ruby1.9.1 rubygems1.9.1

or try building from source. this worked for me on ubuntu 9.04 and after a restart 1.9 was the standard ruby

Gaurav Dave
  • 6,838
  • 9
  • 25
  • 39
user214028
  • 203
  • 1
  • 3
  • i got it working via update-alternatives, as described here: http://krnjevic.com/wp/?p=209 – Martin DeMello Dec 13 '09 at 13:04
  • 1
    I don't see what you're getting at - I installed and rebooted. You can install ruby1.9 either from the source, or via repository. This was the expected behaviour. I didn't sit down and mumble voodoo chants while feverishly typing in commands I thought looked pretty. – user214028 Dec 15 '09 at 11:58