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.

Answer from Mark Rushakoff on Stack Overflow
🌐
Ruby
ruby-lang.org › en › documentation › installation
Installing Ruby | Ruby
It is possible that major package ... its version number. Or use a dedicated installer. Debian GNU/Linux and Ubuntu use the apt package manager....
Discussions

Install later versions of Ruby in Ubuntu 18.04 using apt
You'll want to use rbenv, rvm, chruby, asdf like you normally would. apt packages aren't designed for supporting multiple versions, so you don't want to use them typically. More on reddit.com
🌐 r/ruby
6
6
August 2, 2022
How do I install the latest version of ruby in Ubuntu? - Stack Overflow
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 ... More on stackoverflow.com
🌐 stackoverflow.com
How to I update my version of ruby on Ubuntu?
Zakry Zapata is having issues with: My environment is currently using ruby version 2.2.1, but I have installed ruby 2.2.4, but I am not sure how to get my system to use it. Does an... More on teamtreehouse.com
🌐 teamtreehouse.com
2
December 18, 2015
Will you consider to use official snap Ruby packages instead of rvm/rbenv in production (ubuntu)?
Why would you be using rvm / rbenv in production in the first place? More on reddit.com
🌐 r/ruby
19
4
December 1, 2018
Top answer
1 of 2
19

Why not use ruby 2.3 which is available in the repositories for 16.04 and 17.10 with

sudo apt update

After the update is finished run:

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

Or try ruby 2.4 or 2.5

You can get those via the brightbox PPA

  1. Add the repository and update

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

    sudo apt-get install ruby2.4
    

    or for 18.04

    sudo apt-get install ruby2.5 ruby2.5-dev
    

Information on the status of packages in the aforementioned PPA can be found on the “Brightbox” team launchpad page.

Alternatively you could try reverse hacking the error alternative path /usr/bin/ruby2.2 doesn't exist by creating it with sudo mkdir /usr/bin/ruby2.2 and trying again.

2 of 2
0

On Ubuntu 14.04 this worked for me to install ruby 2.4.1

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Then install rbenv

    cd
    git clone git://github.com/sstephenson/rbenv.git .rbenv
    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
    echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

    git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
    echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
    source ~/.bash_profile

Now install ruby 2.4.1

rbenv install -v 2.2.3

To set 2.4.1 as a default use command rbenv global 2.4.1.

🌐
Chrishammond
chrishammond.com › 2024 › how-to-upgrade-ruby-on-ubuntu-2204-using-rbenv
How to Upgrade Ruby on Ubuntu 22.04 Using rbenv — Chris Hammond
April 18, 2024 - Install rbenv and ruby-build: This step involves pulling rbenv and its plugin ruby-build from GitHub, which helps in managing multiple Ruby versions. sudo apt update sudo apt install -y git curl libssl-dev libreadline-dev zlib1g-dev autoconf ...
🌐
Super User
superuser.com › questions › 1394906 › how-to-update-ruby-version-2-4-1-to-2-5-0-on-ubuntu-18-04
How to update ruby version 2.4.1 to 2.5.0 on Ubuntu 18.04 - Super User
January 16, 2019 - wget http://ftp.ruby-lang.org/pub/ruby/2.5/ruby-2.5.3.tar.gz tar -xzvf ruby-2.5.3.tar.gz cd cd ruby-2.5.3/ ./configure make sudo make install · but this too didn't work as when I run this code to check the version:
🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-rails-on-ubuntu-and-update-ruby-to-the-latest-version
How to Install Rails on Ubuntu and Update Ruby to the Latest Version
July 1, 2020 - Run the command rvm install 2.7.1. Alternatively, you can run rvm install ruby which will install the latest stable version (this will install v2.7.0).
Find elsewhere
🌐
Medium
medium.com › @ernestadonu › upgrade-ruby-to-its-latest-version-e-g-3-2-0-3-2-1-66fe8272948e
Upgrade/Update Ruby to it’s latest versions (e.g. 3.2.0, 3.2.1) | Medium
March 26, 2024 - rbenv global #< ruby version > OR rvm global #< rbuy version > #Based on your package manager to set the path to the latest installed version · If you haven't already, update Rails after the installation is complete.
🌐
Stackify
stackify.com › install-ruby-on-ubuntu-everything-you-need-to-get-going
Install Ruby on Ubuntu: Everything You Need to Get Going - Stackify
February 29, 2024 - If you’re working on an older version of Ubuntu, or aren’t concerned with having the latest version of Ruby, you can use APT. Installation with APT is very straightforward. We’re going to execute a couple of commands, and we’ll be ready ...
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install ruby on ubuntu
How to Install Ruby on Ubuntu | phoenixNAP KB
December 16, 2025 - Note: Learn also how to check Ubuntu version. apt, Ubuntu's built-in package manager, is the fastest and easiest way to install Ruby on Ubuntu. Follow the steps below: Note: Learn more about using the apt package manager and the difference between apt and apt-get. 1. Update the system package ...
Top answer
1 of 2
18

How to get a current Ruby version without messing up your system

Do not mess with your system Ruby, but instead install a current version with either rbenv or RVM. I prefer the first, but both work fine. Note that you can only install one of those at a time.

With such a Ruby version manager, you'll never have to type sudo again to install (or uninstall) a Gem, and you can keep different versions for different projects. You can safely remove these versions again.

Please make sure to read the READMEs of those tools, at least once.

Method 1 – rbenv

rbenv is a version manager for Ruby. It allows you to install a Ruby version alongside your original system Ruby, which means you cannot mess up that one, and you can easily upgrade versions.

To install it, use the rbenv-installer. Make sure to restart your shell once it's installed, and that the rbenv function works.

Then, once rbenv is installed, run rbenv install -l. This gives you a list of available Rubies. Install your chosen one with:

rbenv install 2.5.1

Now choose this one as your default:

rbenv global 2.5.1

As soon as this is done, gem can be used to run:

gem install rails

If the above does not work, you might be missing required packages for building from source. See here for a list of packages that you might want to install. On Ubuntu, these include:

sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev

Method 2 – RVM

You can also install Ruby over RVM. Here as well, you don't need to sudo anything, and you'll be able to get more recent versions of Ruby alongside the system one.

Read the installation instructions for your system.

After installation, you can install Rubies with a simple command. First, check rvm list known to get the list of installable versions. Now install your choice:

rvm install 2.5.1

Then, set it as the default Ruby version for your user:

rvm use 2.5.1 --default

Now you can install Rails over gem:

gem install rails
2 of 2
0

There are multiple ways to install ruby on ubuntu, but installing form the repositories is (currently) not popular. To cleanly get a non-suffixed ruby, you should build ruby yourself or use rvm.

🌐
Linuxize
linuxize.com › post › how-to-install-ruby-on-ubuntu-18-04
How to Install Ruby on Ubuntu 18.04 | Linuxize
September 21, 2018 - To install Ruby using the RVM script, follow these steps: First install the dependencies required for the RVM utility to build Ruby from source: ... sudo apt update sudo apt install curl g++, gcc, autoconf, automake, bison, libc6-dev, libffi-dev, ...
🌐
UbuntuMint
ubuntumint.com › home › how to install ruby on ubuntu using apt, rvm, and rbenv
How to Install Ruby on Ubuntu Using Apt, RVM, and rbenv
December 4, 2023 - $ gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB · Once the keys are imported successfully, run the given command to update and upgrade the installed packages: ... After installing RVM, execute the "source" command to load and execute the RVM script. Once the script is loaded, you can use the "rvm list known" command to display a list of known Ruby versions available for installation:
🌐
Linux Hint
linuxhint.com › install_ruby_ubuntu-2
Install Ruby on Ubuntu 20.04
September 27, 2020 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Tosbourn
tosbourn.com › articles › ruby › upgrading ruby - steps to follow
Upgrading Ruby - Steps to follow
Review of Tosbourn Ltd.
- This is what happens when you change one variable but not the other. Normally the fix is to update the ruby x line in your Gemfile. Or if the Gemfile has the right version, make sure your Ruby version manager is using the correct version of Ruby. How do I update Ruby on Ubuntu? From a Product Manager point of view working with Toby is always a great experience. Not only does he write great code, but his excellent communication skills mean that you know exactly what he needs to get the job done on time and that he can walk you through his decision making process giving you all the information
Rating: 5 ​
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-22-04
How To Install Ruby on Rails with rbenv on Ubuntu 22.04 | DigitalOcean
January 25, 2023 - Last, you’ll use gem to install Rails and can then use Ruby on Rails to begin your web development. You will also learn how to check if your rbenv version is up-to-date, and how to uninstall Ruby versions and rbenv. ... One Ubuntu 22.04 server set up by following the Ubuntu 22.04 initial ...
🌐
Linuxize
linuxize.com › home › ruby › how to install ruby on ubuntu 20.04
How to Install Ruby on Ubuntu 20.04 | Linuxize
October 26, 2021 - The easiest way to install Ruby on Ubuntu is by using the apt package manager. At the time of writing, the version in the Ubuntu repositories is 2.7.0, which may not always be the latest stable release.
🌐
GoRails
gorails.com › setup › ubuntu › 22.04
Install Ruby On Rails on Ubuntu 22.04 Jammy Jellyfish | GoRails
You can find it on the same download link above. The first step is to install dependencies for compiling Ruby. Open your Terminal and run the following commands to install them. sudo apt-get update ...