I tried sudo apt-get install ruby but it will install Ruby 2.1.5.

How could I install version >= 2.1.9 ?

2 Answers 2


There is a ruby 2.3 package in the Raspbian repos, but since apt show ruby on a "jessie" system shows 2.1, I presume this is a "stretch" package -- i.e., part of the the current testing/unstable branch.

However, I ran ldd on it and libruby2.3 and they alone do not have any requirements that aren't part of jessie, so you could install them this way:

  1. Edit /etc/apt/sources.list and add a line:

    deb http://archive.raspbian.org/raspbian/ stretch main
  2. Run apt get update; it may take a while.

Then try apt install ruby2.3. This should work but there are potentially ruby 2.3 gems from the distro that would require a full upgrade of the system to stretch. I have one pi I did this to months ago and it's been fine, but I don't use ruby and only use that pi for particular things, so keep in mind that a full upgrade to testing may (but most likely will not) result in complications.

Upgrading this way may also make using distro gems more complicated -- again, I'm not a ruby user, so the likelihood of this I can't say any more about. Probably installing ruby modules using it's own package management system and not apt would circumvent this. Although apt may end up wanting to install some occasionally anyway as dependencies, they should not take precedence when used.

For some things, using gem instead will require you apt install -dev packages for things the modules are compiled against, and there may be a small number of those which simply won't fly.

Debian (and hence Raspbian) has a conservative policy about versioning, meaning they prefer to stay back from the bleeding edge in the stable branch (currently, jessie), but also maintain a fairly stable "unstable/testing" branch (stretch) -- or it is once it is once it has been in play for a while, which it now has.

So my recommendation is to go for it. You're now aware of the caveats, and of course you should keep your important data backed up anyway, so there is probably not much at risk.

  • thanks but I don't see sources.list in /etc/apt/sources.list.d,just have raspi.list. Do you mean I need to make a new file ?
    – Van Tr
    Commented Jun 9, 2016 at 16:00
  • 1
    Sorry, that should have been /etc/apt/sources.list [fixed above]. I'm not sure what the relevance of using one vs. the other is (if any) but sources.list definitely works.
    – goldilocks
    Commented Jun 9, 2016 at 16:07
  • ok man, it works well.
    – Van Tr
    Commented Jun 9, 2016 at 16:21

Installing Ruby on RPi3 with Raspbian Stretch (9.4)

There are two ways to install ruby on the RPi:

  1. Installing the ruby2.3 APT package.
  2. Using the official RVM install method.

(1) Installing with APT

sudo apt-get install ruby2.3

This will also install the additional dependencies:

libruby2.3 rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet
ruby-power-assert ruby-test-unit ruby2.3 rubygems-integration

However, as is well known, the Raspbian distribution maintainers like to hold back on the version releases, so this package is most likely already outdated, compared to what's available. To get the latest (or even developer) version, use the RVM method below.

(2) Installing with RVM

What is RVM?

The Ruby Version Manager (RVM) is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

The correct way to install Ruby on your RPi is to follow the instructions from one of these locations:

  1. The rvm.io site
  2. The rvm GitHub site

Either way, you are asked to run the script directly from the curl response output, like this.
(Do not use sudo!)

\curl -sSL https://get.rvm.io | bash -s stable --ruby

However, this is not generally recommended, for obvious security reasons, as you have no idea what is happening or going on!

So instead do the following.

cd ~/Downloads/
\curl -sSL https://get.rvm.io -o rvm-installer
# ^^ That actually resolve to:
# curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer -o rvm-installer

chmod 755 rvm-installer

Downloading https://github.com/rvm/rvm/archive/master.tar.gz
Installing RVM to /home/pi/.rvm/
    Adding rvm PATH line to /home/pi/.profile /home/pi/.mkshrc /home/pi/.bashrc /home/pi/.zshrc.
    Adding rvm loading line to /home/pi/.profile /home/pi/.bash_profile /home/pi/.zlogin.
Installation of RVM in /home/pi/.rvm/ is almost complete:

  * To start using RVM you need to run `source /home/pi/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

. /home/pi/.rvm/scripts/rvm
rvm list

# No rvm rubies installed yet. Try 'rvm help install'.

rvm list known

# MRI Rubies
[ruby-]1.8.7[-head] # security released on head

Unfortunately rvm-installer help doesn't show one of the most useful hidden option: rvm-installer stable --ruby.

Also, as noted, when you ran the rvm-installer, the following files were modified to add some new rvm related stuff.


If you don't like this, make sure to pass the --ignore-dotfiles option to the rvm-installer. If you do so, you will need to manually do this:

echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile

Next, we check what stable Ruby version is actually recommended:

rvm install ruby-2.5.1 --binary         # this binary doesn't exist!
date; time rvm install ruby-2.5.1 -j 4  # we compile with 4 threads, 
                                        # this take ~XX min on a RPi3 

Once this has finsihed, I can also complete this answer...

The point here, is that rvm seem far more userfriendly, once the binaries has been created. Why these are not already widely available for the RPi3, seem quite crazy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.