How to update ruby on linux (ubuntu)?

162,778

Solution 1

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.

Solution 2

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

Solution 3

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

Solution 4

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

Solution 5

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.

Share:
162,778

Related videos on Youtube

eKek0
Author by

eKek0

I'm a software developer living in Santiago del Estero, one of the smallest towns in Argentina. I'm also a system analyst, and program in Delphi and ASP.NET with C#. Currently, I'm working in a bank developing in-house software.

Updated on February 07, 2020

Comments

  • eKek0
    eKek0 over 4 years

    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?

  • khylo
    khylo almost 12 years
    On ubuntu 12 you need to specify v1.9.1, i.e sudo apt-get install ruby1.9.1 rubygems1.9.1
  • Adam Miller
    Adam Miller almost 12 years
    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!
  • Ben Walding
    Ben Walding about 11 years
    If you don't need multiple versions (e.g. a production machine) then it's best to avoid RVM and just use ruby-build.
  • logan
    logan about 11 years
    You could also update ruby to point to ruby 1.9. Check out stackoverflow.com/questions/1892877
  • Konrad Reiche
    Konrad Reiche over 10 years
    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
  • xji
    xji over 8 years
    @AdamMiller update-alternatives shows "no alternative for ruby"?
  • Adam Miller
    Adam Miller over 8 years
    This comment I made is ages old, and is no longer relevant due to changes made in the repositories.
  • steenslag
    steenslag over 8 years
    Ruby is v2.3 now. Ruby 2.0 maintenance ends 16 February 2016.
  • Mincong Huang
    Mincong Huang about 8 years
    E: Unable to locate package ruby2.3 @steenslag
  • steenslag
    steenslag about 8 years
    @MincongHuang I think Debian's (and Ubuntu) default Ruby version is now 2.1 (wiki.debian.org/Ruby); with rvm you don't have to wait for the package managers.
  • Zoe stands with Ukraine
    Zoe stands with Ukraine about 5 years
    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