44

I wonder about installing the latest version of Ruby on Ubuntu 9.04. Now I can run through the ./configure and make stuff fine, but what I wonder about: how to avoid conflicts with the packaging system? For example if some other package I install depends on Ruby, wouldn't the package manager install the (outdated) Ruby package and in the worst case overwrite my files?

So I think I need some way to tell Ubuntu that Ruby is in fact already installed?

Caramiriel
  • 7,029
  • 3
  • 30
  • 50
Björn
  • 1,183
  • 2
  • 13
  • 18
  • So, out of pure curiosity, is there any reason to have the absolute latest version of ruby? I mean it's great to be bleeding edge, but is there actually any features that you need that this newest version has that the older versions don't? If there isn't, it seems a bit unnecessary to upgrade. – thebrokencube Jul 10 '09 at 15:03
  • 11
    I think so - it has unicode support, for one thing, is much faster, and supposedly has fixed some memory leaks of the older versions. I am not a specialist on Ruby, though. However, I am developing on a Mac and I noticed that Ruby 1.9.1 that comes with MacPorts is not compatible with the 1.9.0 version that comes with Ubuntu. Unicode really is the biggie for me, though. I heard that it works in Rails with Ruby 1.8, but I couldn't get any definite info on it. Also I don't have only Rails apps, also standalone Ruby. – Björn Jul 10 '09 at 15:15
  • 3
    Ruby 1.9.1 (patch 243) ships as a package in karmic koala. – Sam Saffron Dec 03 '09 at 06:43
  • it's quite odd that even for ubuntu 10.10 ruby 1.9.1 shows as virtual. Why can't you just install it with apt? weirdness. – Thufir Jan 24 '12 at 09:35

8 Answers8

61

Save yourself the headache and use RVM (Ruby Version Manager)

Keep in mind, Rails 3 works best with Ruby 1.9.2. Ruby 1.9.2 fixes up quite a few bugs in 1.9.1 and is preferable to running 1.9.1.

With RVM installing 1.9.2 is a breeze.

Daniil Shevelev
  • 11,739
  • 12
  • 50
  • 73
Sam Saffron
  • 128,308
  • 78
  • 326
  • 506
  • 2
    +1000 I finally got around to trying this on OSX today, and it's brilliant. This page was particularly helpful: http://www.rubyinside.com/rvm-ruby-version-manager-2347.html – Dan Rosenstark May 17 '10 at 11:27
  • My world has been ROCKED! I should have checked into this sooner. =] RVM is awesome! – Andrew Oct 14 '10 at 23:40
  • 2
    while `rvm install 1.9.1` seems like a nice and friendly command, it led me down a horrible two hour long trail of broken patches. Save your sanity, just install it from apt-get. rvm is nice when it works like most everything ruby. – Milimetric Oct 23 '12 at 20:51
  • 1
    `rvm` is a very complicated beast. While it make work for some, I wasted half a day with it. Ubuntu 12.10 comes with Ruby 1.9.3, so there is little reason to mess with `rvm`. – Ross Smith II Nov 04 '12 at 23:54
  • @RossSmithII I am curious to hear why this played up for you, I bet you tried installing rvm with sudo – Sam Saffron Nov 05 '12 at 01:36
  • I've spent almost all day trying to install ruby using rvm on Ubuntu 12.10, and I didn't use sudo. mapasis was very helpful in #rvm. I think we found a solution, and if it reliably works, I will post to https://rvm.io/ – Ross Smith II Nov 05 '12 at 05:20
  • This saved me from the horror! http://stackoverflow.com/questions/9056008/installed-ruby-1-9-3-with-rvm-but-command-line-doesnt-show-ruby-v/9056395#9056395 – mlunoe Jun 26 '14 at 05:22
34
sudo apt-get install ruby1.9.1-full

(http://www.ruby-lang.org/en/downloads/)

Ian Vaughan
  • 20,211
  • 13
  • 59
  • 79
28

After running

sudo apt-get install ruby1.9.1-full

It's solution is to run the following command:

sudo update-alternatives --config ruby

Then you will get this output:

   There are 2 choices for the alternative ruby (providing /usr/bin/ruby).

     Selection    Path                Priority   Status
   ------------------------------------------------------------
   * 0            /usr/bin/ruby1.8     50        auto mode
     1            /usr/bin/ruby1.8     50        manual mode
     2            /usr/bin/ruby1.9.1   10        manual mode

   Press enter to keep the current choice[*], or type selection number: 2
   update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in    manual mode.
   $ ruby --version
   ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

Credit for this solution goes to person who answered https://askubuntu.com/questions/91693/how-do-you-uninstall-ruby-1-8-7-and-install-ruby-1-9-2 . Currently the ruby1.9.1 package is actually ruby 1.9.2.

Community
  • 1
  • 1
kristianp
  • 5,496
  • 37
  • 56
  • 1
    Thanks for this - I just blew half a day uninstalling, re-installing, compiling and recompiling from source, then using rvm, all the while wondering why 'ruby -v' doggedly kept returning 1.8.7. I don't know why this isn't at the least on the RVM install page. – ctd Jun 18 '12 at 23:26
  • `sudo apt-get install ruby1.9.1-full` doesnt work anymore – Idemax Jul 29 '16 at 14:57
  • `sudo apt-get install ruby-full` is probably the install command these days (I haven't tried that out yet though). – kristianp Sep 04 '16 at 23:30
7

The way I did it was to build it using checkinstall which lets you build a deb package. So I downloaded the Ruby 1.9.1 source, did a "configure" and then "make", did a "checkinstall" and made the package name ruby1.9 so it installs as if it were a new version of ruby 1.9 (as it should).

4

I got the Ruby specific info from this site. You can install most software in a different directory with the --prefix=/path switch. And it is common to install in /opt/ for everyone on your pc, or in $HOME if it is only for you.

For installing in /opt:

$ ./configure –prefix=/opt/ruby
$ make install

If you want to use the /opt installed ruby, edit you ~/.bashrc and add

export PATH=/opt/ruby/bin/:$PATH

If you don't want to have the custom Ruby build as default, you can add this to your ~/.bashrc instead of the former command

function setupruby {
     export PATH=/opt/ruby/bin/:$PATH
}
Dykam
  • 10,190
  • 4
  • 27
  • 32
4

Here is a short and convenient way to install 1.9.1 and to make it default: http://michalf.me/blog:make-ruby-1-9-default-on-ubuntu-9-10-karmic-koala

1

I created a launchpad ppa for ruby 1.9.2. Details in the links below

http://www.humbug.in/2010/launchpad-ppa-for-ruby-1-9-2-and-some-ruby-bindings/

sudo add-apt-repository ppa:pratikmsinha/ruby192+bindings
cd /etc/apt/sources.list.d/; sudo mv pratikmsinha-ruby192+bindings-lucid.list pratikmsinha-ruby192bindings-lucid.list
sudo aptitude update
sudo aptitude install ruby1.9.2
freethinker
  • 1,286
  • 1
  • 10
  • 17
0

Looking through Synaptic it seems like you don't even have to deal with the Multiverse or third-party repositories. But since sudo apt-get install ruby currently installs an alias to ruby1.8, you should install ruby1.9 explicitly – manually or via the repositories – and create the alias ruby yourself.

You may want to put the binary in /usr/bin since that's where the distribution would put it anyway. Anywhere on your PATH is fine, though.

Nikhil
  • 5,705
  • 1
  • 32
  • 30
  • My impression was that in the repositories there is only Ruby 1.9.0, which seems to be incomptible with Ruby 1.9.1. However, 1.9.1 is supposed to be the final release, 1.9.0 is just development version from whenever. – Björn Jul 10 '09 at 15:17
  • You're right. Looks like you'll have to build it yourself for now. – Nikhil Jul 10 '09 at 22:56