Categories: Ubuntu

How to Install RubyGems on Ubuntu 22.04

RubyGems is a package manager for Ruby that allows users to install packages and libraries required for creating Ruby projects. It also helps users in creating new applications or programs and managing them through gems. RubyGems is hosted by the Ruby community and it makes the installation of Gems simple on the system.

To install RubyGems on the Ubuntu system, follow this article’s guide.

How to Install RubyGems on Ubuntu 22.04

The Ubuntu users can install RubyGems on the system from:

Method 1: Install RubyGems on Ubuntu Through Repository

The Ubuntu official repository makes it simple for the users to install RubyGems on the system. However, before installing any application or packages from the source repository, the users must ensure updating the repository through the following command:

$ sudo apt update && sudo apt upgrade -y

 

After updating Ubuntu repository, the users can install RubyGems on the system from the following command:

$ sudo apt install rubygems -y

 

You can confirm the RubyGems version on Ubuntu from the following command:

$ gem -v

 

Method 2: Install RubyGems on Ubuntu Manually Through tgz

The Ubuntu repository won’t install an updated version of RubyGems on the system. Thus, you have to manually install an updated version of RubyGems from the following steps mentioned in this method.

Step 1: Ensure Ruby is installed on the Ubuntu system and if not, the users can use the following command to install Ruby on Ubuntu.

$ sudo apt install ruby -y

 

Note: The above steps install RubyGems on Ubuntu too but it won’t be the updated version.

Step 2: You have to download the RubyGems latest version tgz source file from the wget command on the terminal.

$ wget https://rubygems.org/rubygems/rubygems-3.4.6.tgz

 

Step 3: Extract the RubyGems source file on Ubuntu through the following command:

$ tar -xf rubygems-3.4.6.tgz

 

Step 4: Navigate to RubyGems source directory from the following command:

$ cd rubygems-3.4.6

 

Step 5: Then use the following command to install the latest version of RubyGems on the Ubuntu system.

$ sudo ruby setup.rb

 

Step 6: You can confirm the installation of RubyGems latest version from the following command:

$ gem -v

 

Conclusion

RubyGems can easily be installed through the official Ubuntu repository via the “apt” command. However, it fails to install the updated version of RubyGems. The users can choose the manual installation method to successfully install the updated version of RubyGems on the Ubuntu system. The manual method requires Ruby and the latest version tgz source file, which can be downloaded on Ubuntu system from the “wget” command.

Ubuntu Server Admin

Recent Posts

Shoryuken Has a New Maintainer, and v7.0.0 Is Almost There

After a decade under Pablo Cantero's stewardship, Shoryuken has a new maintainer - me. I'm…

4 days ago

A better way to provision NVIDIA BlueField DPUs at scale with MAAS

MAAS 3.7 has been officially released and it includes a bunch of cool new features.…

2 weeks ago

Ruby Floats: When 2.6x Faster Is Actually Slower (and Then Faster Again)

Update: This article originally concluded that Eisel-Lemire wasn't worth it for Ruby. I was wrong.…

2 weeks ago

MicroCeph: why it’s the superior MinIO alternative (and how to use it)

Recently, the team at MinIO moved the open source project into maintenance mode and will…

2 weeks ago

MicroCeph: why it’s the superior MinIO alternative (and how to use it)

Recently, the team at MinIO moved the open source project into maintenance mode and will…

2 weeks ago

Design and Documentation clinics at FOSDEM Fringe 2026

FOSDEM is one of the biggest and most exciting open source events of the year,…

2 weeks ago