UbuntuUbuntu Based

How To Install Ruby on Ubuntu 24.04 LTS

Install Ruby on Ubuntu 24.04

In this tutorial, we will show you how to install Ruby on Ubuntu 24.04 LTS. Ruby, a dynamic and versatile programming language, has gained immense popularity among web developers for its simplicity and powerful features. As an open-source language, Ruby offers a wide range of tools and frameworks, such as Ruby on Rails, that streamline the development process. Ubuntu 24.04, the latest LTS release of the popular Linux distribution, provides a stable and secure platform for running Ruby applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Ruby programming language on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install Ruby on Ubuntu 24.04 LTS Noble Numbat

Step 1. Updating the Package Repository.

To prepare your system for Ruby installation, run the following commands to update the package lists and install essential packages:

sudo apt update

Step 2. Installing Ruby on Ubuntu 24.04.

  • Method 1: Installing Ruby via Snap Package

Snap packages provide a convenient and streamlined way to install applications on Ubuntu. Snaps are self-contained packages that include all the necessary dependencies, making the installation process straightforward and hassle-free. To install Ruby using the Snap package, follow these steps:

snap install ruby --classic

Wait for the installation to complete. Snap will download and install the latest stable version of Ruby.

Verify the installation by running:

ruby --version

Snap packages provide a quick and easy way to get started with Ruby on Ubuntu 24.04. However, keep in mind that Snap packages may not always include the latest version of Ruby or specific versions you might require for your projects.

  • Method 2: Installing Ruby from the System Repository

Ubuntu’s system repository offers a version of Ruby that is tested and maintained by the Ubuntu community. While this method may not provide the latest Ruby version, it ensures compatibility with the operating system. To install Ruby from the system repository, follow these steps:

sudo apt install ruby-full

Once the installation is complete, verify the installed version by running:

ruby --version

Installing Ruby from the system repository is a straightforward approach and ensures compatibility with Ubuntu 24.04. However, the version provided by the repository may not always be the latest stable release, and upgrading to newer versions may require additional steps.

  • Method 3: Installing Ruby via rbenv

rbenv is a lightweight Ruby version management tool that allows you to easily install and switch between multiple Ruby versions on your system. It provides a flexible and user-friendly way to manage Ruby installations. To install Ruby using rbenv, follow these steps:

sudo apt install rbenv

Install the last version of Ruby using rbenv. For example, to install Ruby 3.3.0, run:

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Verify the installation by running:

ruby --version
  • Method 4: Installing Ruby via RVM.

RVM (Ruby Version Manager) is a powerful command-line tool that allows you to install, manage, and work with multiple Ruby environments. It provides a convenient way to install and switch between different Ruby versions and manage gem sets. To install Ruby using RVM, follow these steps:

First, install the GPG keys for RVM by running:

gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Install RVM with the latest stable version of Ruby by running:

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

Once the installation is complete, load RVM into your shell by running:

source ~/.rvm/scripts/rvm

Verify the installation by running:

ruby --version

Step 3. Troubleshooting Common Issues

If you encounter any issues during the Ruby installation process, here are a few troubleshooting tips:

  • Ensure that you have the necessary dependencies installed before proceeding with the installation.
  • If you encounter permission-related errors, try running the commands with sudo or as a root user.
  • If you face issues with OpenSSL, make sure you have the OpenSSL development libraries installed (libssl-dev package on Ubuntu).
  • If you are using rbenv or RVM, ensure that the correct Ruby version is set as the global or default version.
  • Consult the official documentation or community forums for the specific installation method you are using for further assistance.

Congratulations! You have successfully installed Ruby. Thanks for using this tutorial for installing Ruby programming language on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Ruby website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button