20

I currently have ruby version 1.8.2 in my machine and I would like to upgrade it to 1.9.2. How am i supposed to do it?

Rahul
  • 44,892
  • 25
  • 73
  • 103
  • 1
    possible duplicate of [Installing Ruby 1.9.1 on Ubuntu?](http://stackoverflow.com/questions/1109695/installing-ruby-1-9-1-on-ubuntu) – knittl Aug 14 '11 at 15:00
  • Which version of ubuntu are you running? I am running 11.04 and Ruby 1.9.1 is available in Synaptic package manager. – yasouser Aug 14 '11 at 15:08

8 Answers8

29

I use Ubuntu, and I've found the easiest way to install newer versions of Ruby is to use rvm.

The instructions are here: https://rvm.io/rvm/install/

Basically, it installs different versions of Ruby locally for the user and updates environment variables for Ruby and gems based on which version you decide to use.

It's this easy:

jim@schubert:~$ rvm use system
Now using system ruby.
jim@schubert:~$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
jim@schubert:~$ gem -v
1.3.7
jim@schubert:~$ rvm use 1.9.2
Using /home/jim/.rvm/gems/ruby-1.9.2-p180
jim@schubert:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
jim@schubert:~$ gem -v
1.5.2
jim@schubert:~$ 
mpapis
  • 52,729
  • 14
  • 121
  • 158
Joseph Yaduvanshi
  • 20,241
  • 5
  • 61
  • 69
16

I don't like having RVM on production server, so I usually install ruby from source with an install script like this:

#!/bin/bash

tmp_dir="/tmp"
version="2.2.3"
minor_version="2.2"
ruby_version="ruby-$version"

echo "*******************"
echo "* Installing Ruby *"
echo "*******************"

sudo apt-get install -y autoconf build-essential libreadline-dev libssl-dev libyaml-dev zlib1g-dev libffi-dev

mkdir -p "$tmp_dir"
cd "$tmp_dir"

wget "http://cache.ruby-lang.org/pub/ruby/$minor_version/$ruby_version.tar.gz"
tar -xvzf $ruby_version.tar.gz
cd $ruby_version

./configure --disable-install-doc
make --jobs `nproc`
sudo make install

cd ..
rm $ruby_version.tar.gz
rm -rf $ruby_version

echo "*******************"
echo "* Ruby installed! *"
echo "*******************"
Lasse Skindstad Ebert
  • 3,370
  • 2
  • 29
  • 28
13

1 Install RVM:

https://rvm.io

2 Then install Ruby 1.9.2

rvm install 1.9.2
mpapis
  • 52,729
  • 14
  • 121
  • 158
fl00r
  • 82,987
  • 33
  • 217
  • 237
7

Since the original question was about the latest version, here is how to get Ruby 2.2.

apt-add-repository ppa:brightbox/ruby-ng
apt-get update
apt-get install ruby2.2

Here is how to get Ruby 2.3.

apt-get install ruby2.3 ruby2.3-dev

Info on brightbox's maintainance of these.

Joshua Cook
  • 12,495
  • 2
  • 35
  • 31
4

Using sudo apt-get install ruby-full you will get old version of ruby (1.9) currently existing in Ubuntu repos. You might want to check installation from source

Download ruby tar from here and then run:

$ tar -xf ruby-X.X.X.tar.gz
$ cd ruby-X.X.X
$ ./configure
$ make
$ sudo make install

In some cases you will need to realod bash by typing:

$ bash
wolendranh
  • 4,202
  • 1
  • 28
  • 37
2

I might came late but this is a very useful website that provides Ubuntu packages and it seems to be maintained and up-to-date. Look here.

Anastasios Andronidis
  • 6,310
  • 4
  • 30
  • 53
  • Exactly what I wanted! Thank you! Note that `apt` may not install the *latest* Ruby version automatically, because the `brightbox.com` repository may specify an earlier version as preferred. For example, if `apt install ruby` installs `ruby2.3` but you want 2.4, be explicit, e.g., `apt install ruby2.4`. – Ben Johnson Nov 28 '17 at 14:56
2

It depends on what Ubuntu version you are running, you can get the ruby packages with this link http://packages.ubuntu.com/search?keywords=ruby1.9.1&searchon=names&suite=all&section=all, to get the latest Ruby(1.9.2-p290) installed, you have to upgrade your Ubuntu to oneiric, if you don't like to upgrade your system, maybe you have to install Ruby with RVM as fl00r answered.

Xiaohui Zhang
  • 985
  • 8
  • 12
0

You should check stackoverflow more carefully before asking questions.

Installing Ruby 1.9.1 on Ubuntu?

sudo apt-get install ruby1.9.1-full
Community
  • 1
  • 1
thenengah
  • 42,557
  • 33
  • 113
  • 157