46

I'm newbie on both ruby and linux, so I'm sure this is trivial but I don't know yet. I currently have ruby 1.8.7 installed and I want to update it to ruby 1.9. How can I do that?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
eKek0
  • 23,005
  • 25
  • 91
  • 119

9 Answers9

57
sudo apt-get install ruby1.9

should do the trick.

You can find what libraries are available to install by

apt-cache search <your search term>

So I just did apt-cache search ruby | grep 9 to find it.

You'll probably need to invoke the new Ruby as ruby1.9, because Ubuntu will probably default to 1.8 if you just type ruby.

Mark Rushakoff
  • 249,864
  • 45
  • 407
  • 398
  • You could also update ruby to point to ruby 1.9. Check out http://stackoverflow.com/questions/1892877/ – logan Apr 09 '13 at 20:23
37

There's really no reason to remove ruby1-8, unless someone else knows better. Execute the commands below to install 1.9 and then link ruby to point to the new version.

sudo apt-get install ruby1-9 rubygems1-9
sudo ln -sf /usr/bin/ruby1-9 /usr/bin/ruby
Matthew Cordaro
  • 677
  • 1
  • 7
  • 26
Chris
  • 399
  • 2
  • 5
  • 4
    On ubuntu 12 you need to specify v1.9.1, i.e sudo apt-get install ruby1.9.1 rubygems1.9.1 – khylo Jul 03 '12 at 19:10
  • 8
    Actually, you shouldn't edit the links yourself, you should you the commands: sudo update-alternatives --config gem and sudo update-alternatives --config ruby. I suggest that this answer be edited! – Adam Miller Jul 17 '12 at 20:18
  • 1
    @AdamMiller `update-alternatives` shows "no alternative for ruby"? – xji Dec 31 '15 at 08:19
  • This comment I made is ages old, and is no longer relevant due to changes made in the repositories. – Adam Miller Dec 31 '15 at 16:08
16

On Ubuntu 12.04 (Precise Pangolin), I got this working with the following command:

sudo apt-get install ruby1.9.1
sudo apt-get install ruby1.9.3
Zorayr
  • 23,770
  • 8
  • 136
  • 129
11

Ruby is v2.0 now. Programs like Jekyll (and I am sure many others) require it. I just ran:

sudo apt-get install ruby2.0

check version

ruby --version

Hope that helps

user7542
  • 111
  • 1
  • 2
8

The author of this article claims that it would be best to avoid installing Ruby from the local packet manager, but to use RVM instead.

You can easily switch between different Ruby versions:

rvm use 1.9.3

etc.

Konrad Reiche
  • 27,743
  • 15
  • 106
  • 143
  • 4
    If you don't need multiple versions (e.g. a production machine) then it's best to avoid RVM and just use ruby-build. – Ben Walding Mar 07 '13 at 08:44
  • 1
    After a year of Ruby I must say RVM was the best choice I could have made. On Christmas 2013 I updated to Ruby 2.1 seamlessly. It is really a well-crafted tool – Konrad Reiche Jan 30 '14 at 13:18
  • Raspbian: tried one other manager before using RVM (mainly because I couldn't find the source code for RVM and the copyright on the website made it look like the project look dead). The other one failed to compile stuff, so I gave rvm a second try , and it worked a lot better. It also installed some of the missing packages I needed for the compilation. Works like a charm on distros without a decently updated apt repo – Zoe Mar 22 '19 at 21:28
4

the above is not bad, however its kinda different for 11.10

sudo apt-get install ruby1.9 rubygems1.9

that will install ruby 1.9

when linking, you just use ls /usr/bin | grep ruby it should output ruby1.9.1

so then you sudo ln -sf /usr/bin/ruby1.9.1 /usr/bin/ruby and your off to the races.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
kenobi
  • 41
  • 1
1

If you are like me using ubuntu 10.10 & cant find the lastest version which is now

  • ruby1.9.3

this is where you can get it http://www.ubuntuupdates.org/package/brightbox_ruby_ng_experimental/maverick/main/base/ruby1.9.3

or download the *.deb file :)

& remember that it wont alter you old version of ruby

ucefkh
  • 2,509
  • 2
  • 22
  • 18
1

First, which version of ubuntu are you using, it might be easiest to just upgrade to one that has it.

Next, enable backports (system menue, adminstration, software sources), and search for in in synaptic.

Last, look for a ppa for it.

0

Generally the verions of programs are linked to the version of your operating system. So if you were running gutsy you would either have to upgrade to the new jaunty jackalope version which has ruby 1.9 or add the respoistories for jaunty to your /etc/apt/sources.list file. Once you have done that you can start up the synaptic package manager and you should see it in there.

mikewilliamson
  • 24,303
  • 17
  • 59
  • 90