Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Installing Ruby on Linux
2.1.
Ruby on Red Hat Enterprise and Fedora Linux
2.2.
Ruby on Ubuntu and Debian Linux
3.
Frequently Asked Questions
3.1.
In which programming language is Ruby written?
3.2.
Define the best way to install Ruby on Linux.
3.3.
Which installation manager is used by Red Hat Enterprise and Fedora Linux?
3.4.
Which tool is used by Debian and Ubuntu to manage package installation?
3.5.
Which command is used to install Ruby?
4.
Conclusion
Last Updated: Mar 27, 2024

Installing Ruby on Linux

Author Prachi Singh
0 upvote
gp-icon
Data structures & algorithms (Beginner to Intermediate)
Free guided path
13 chapters
99+ problems
gp-badge
Earn badges and level up

Introduction

Ruby is itself written in the C programming language. This means either a binary distribution for users' chosen operating system and hardware platform must be installed, or the Ruby sources must be downloaded and compiled on your target system. While compiling Ruby yourself might be fun, it usually makes more sense to download and install one of the many pre-built Ruby packages rather than attempt to build your own. This blog will cover installing pre-built Ruby packages on each platform.

Installing Ruby on Linux

Several different distributions are available today, and installing the Ruby package built specifically for your chosen Linux flavour makes sense. The best way to do this is to use the standard package manager for that particular Linux.

Ruby on Red Hat Enterprise and Fedora Linux

Red Hat Enterprise Linux and Fedora Linux use the YUM installation manager and the Red Hat Package Manager (rpm). The first step is to verify if Ruby is already installed. This can be achieved using the following rpm command. In this example, Ruby is not yet installed:

rpm -q ruby
package ruby is not installed


If Ruby is not installed, it can be installed using the yum update manager. This needs to be performed as root, so the superuser password will be required in the following steps:

su -
yum install ruby


The yum tool will locate the ruby package and any other packages on which Ruby is dependent and prompt you to install the packages:

Downloading Packages:
(1/2): ruby-1.8.1-7.EL4.8 100% |                         | 156 kB    00:10
(2/2): ruby-libs-1.8.1-7. 100% |                         | 1.5 MB    01:23
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: ruby-libs                    ######################### [1/2]
  Installing: ruby                         ######################### [2/2]

Installed: ruby.i386 0:1.8.1-7.EL4.8
Dependency Installed: ruby-libs.i386 0:1.8.1-7.EL4.8
Complete!

once the installation is complete, you may re-run the rpm command to verify the package is now installed.

Ruby on Ubuntu and Debian Linux

Debian, Ubuntu, and other Debian-derived Linux distributions use the apt-get tool to manage package installation. If you are running Ubuntu Linux and get the following output from the ruby command, you need to install Ruby:

$ ruby
The program 'ruby' is currently not installed.  You can install it by typing:
sudo apt-get install ruby
-bash: ruby: command not found.


To install ruby, simply run the apt-get command as instructed in the message:

sudo apt-get install ruby.


The apt-get tool will display output listing any other packages required by Ruby (better known as dependencies):

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libruby1.8 ruby1.8
Suggested packages:
  ruby1.8-examples rdoc1.8 ri1.8
The following NEW packages will be installed:
  libruby1.8 ruby ruby1.8
0 upgraded, 3 newly installed, 0 to remove and 135 not upgraded.
Need to get 1769kB of archives.
After unpacking 6267kB of additional disk space will be used.
Do you want to continue [Y/N]
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Frequently Asked Questions

In which programming language is Ruby written?

C programming language.

Define the best way to install Ruby on Linux.

The best way to do this is to use the standard package manager for that particular Linux.

Which installation manager is used by Red Hat Enterprise and Fedora Linux?

Red Hat Enterprise Linux and Fedora Linux use the YUM installation manager and the Red Hat Package Manager (rpm). 

Which tool is used by Debian and Ubuntu to manage package installation?

Debian, Ubuntu, and other Debian-derived Linux distributions use the apt-get tool to manage package installation.

Which command is used to install Ruby?

apt-get command is used to install Ruby.

Conclusion

After reading about Installing Ruby, are you not feeling excited to read/explore more articles on the Installation of Ruby? Don't worry; Coding Ninjas has you covered.

However, you may want to pursue our premium courses to give your job an advantage over the competition!

With our Coding Ninjas Studio Guided Path, you may learn about Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and more! Check out the mock test series and participate in the contests on Coding Ninjas Studio if you want to put your coding talents to the test! However, if you've just started school and are looking for answers to concerns raised by digital behemoths such as Amazon, Microsoft, Uber, and others. As part of your placement preparations, you must evaluate the obstaclesinterview experiences, and interview package in this case. Please vote for our blogs if you find them valuable and exciting.

Happy studying!!

Next article
Installing Ruby on Red Hat Enterprise and Fedora Linux
Guided path
Free
gridgp-icon
Data structures & algorithms (Beginner to Intermediate)
13 chapters
109+ Problems
gp-badge
Earn badges and level up
Live masterclass