Debian

How to Install RubyGems on Debian

RubyGems is an open-source package manager for Ruby that makes it easy for system users to install Ruby packages and libraries. With the help of these packages and libraries, users can create new applications or programs and manage them via gems.

Follow this article’s guidelines to install RubyGems on the Debian system.

Install RubyGems on Debian

The Debian users can install RubyGems via

Method 1: Install RubyGems on Debian Via Source Repository

You can find RubyGems installation inside the Debian source repository, making it easy for the user to install it on Debian from the apt command. However, before installing RubyGems from the Debian repository, you must update the repository from the following command:

sudo apt update && sudo apt upgrade -y

Then, install RubyGems from the Debian repository using the following command:

sudo apt install rubygems -y

To confirm the RubyGems installation on Debian, run the below-given command:

gem -v

Method 2: Install RubyGems on Debian from tgz Source File

The above method won’t be able to install the updated RubyGems version on Debian system. Thus, if you want to install and update the RubyGems version on the Debian system, follow the below-given steps:

Step 1: First, you must ensure Ruby is installed on Debian and if not, you can run the below-given command to install it.

sudo apt install ruby -y

Note: If you run the above command, it also installs the RubyGems on Debian, but it won’t be the updated version.

Step 2: If you want to download the latest version RubyGems on Debian, grab the latest version tgz source file, and download it on the terminal.

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

Step 3: After downloading the tgz source, you can extract it in the Debian home directory from the following command:

tar -xf rubygems-3.4.6.tgz

Step 4: Open RubyGems source directory using the following command:

cd rubygems-3.4.6

Step 5: After that, run the setup.rb file using Ruby to install the latest version of RubyGems on the Debian system.

sudo ruby setup.rb

Step 6: To confirm the latest version of Ruby is installed on Debian, use the following command:

gem -v

Conclusion

The Debian users can install RubyGems on the system from the source Debian repository through the “apt” command. However, the users won’t be able to install the latest version through this method. Installing the latest version of RubyGems on Debian is possible if users follow the second method from the tgz source file and the installation steps are already provided in the above-mentioned guidelines.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.