How to install Ruby on Debian 11

Ruby language is a combination of Perl, Smalltalk, Eiffel, Ada, and Lisp languages, and it is also the combination of imperative language along with the functional language. It was introduced in 1995 and got a boom in popularity in 2006. It has a well-defined structure of syntax, which is why it is used in most games development, web development, and also behind the ruby-on-Rails framework. In this article, we will learn how to install Ruby on Debian 11.

How to install Ruby on Debian 11

Ruby can be installed on Debian 11 by different methods which are

  • From Debian 11 repository
  • Using with Rbenv

Explanations of these methods are described in detail.

Installation using Debian 11 repository

First, we will update the repository of Debian 11 to update all the packages of the repository.

$ sudo apt update

Then we will start the installation of Ruby by using the command:

$ sudo apt install ruby-full -y

To verify the installation we will check the version of Ruby using the command of the version.

$ ruby --version

To uninstall the ruby from Debian 11 we will execute the command:

$ sudo apt purge ruby -y

Installation of Ruby using the Rbenv:

Rbenv is a tool that contains a variety of versions of Ruby on distributions of Linux. In Debian 11, we will install the Rbenv, then using it we can install any available version of Ruby in Debian 11. Before installing Rbenv, it is recommended to update the repository of Debian 11 once again using the command:

$ sudo apt update

Now, as all the packages are up to date, install the Rbenv using the apt command from the repository of Debian 11:

$ sudo apt install rbenv -y

To verify installation, we will check the version of the installed rbenv by using the command:

$ rbenv -v

To list down the version of Ruby available in rbenv, execute the command:

$ rbenv install -l

Now let’s suppose we want to install Ruby 2.7.0 using rbenv, then we have to run the command:

$ rbenv install 2.7.0

For the verification of the installation of Ruby, run the command:

$ ruby -v

Conclusion

Ruby is a general-purpose language but used mainly for web development applications and the implementation of the ruby on rails is also well known. In this article, we have learned the installation procedure of Ruby on Debian 11 by two methods; one is using the directly installing the ruby from the repository of Debian 11, and the other one is, by installing the rbenv on Debian 11 that contains a variety of versions of Ruby among which we can install depending upon our wish.