How to install RubyGems on Linux

Question: I am trying to install a Ruby application package from RubyGems, but I'm getting the following error when attempting to install a Ruby package. How can I install RubyGems on [insert your Linux distro]?

"bash: gem: command not found"

RubyGems is a package manager for building, uploading, downloading and installing Ruby packages (also called "Gems"). When you install a Gem package, RubyGems automatically downloads and installs the Gem and all its dependencies/libraries.

Here is an instruction on how to install RubyGems on various Linux distros. When you install RubyGems, you also want to install Ruby development environment as well, which is needed to build Ruby extensions which are typically written in C language.

On Debian, Ubuntu or Linux Mint:

$ sudo apt-get install rubygems ruby-dev

On CentOS, Fedora or RHEL:

$ sudo yum install rubygems ruby-devel

On Arch Linux, RubyGems is included in the ruby package. So install ruby package from AUR. Then install development tools as well:

$ sudo pacman -S base-devel

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Leave a comment

Your email address will not be published. Required fields are marked *