Ruby is one of the most popular languages today. It has an elegant syntax and is the language behind the Ruby on Rails framework.
In the tutorial, we will look at different ways to install Ruby on Debian 10.
We will show how to install Ruby from the default Debian 10 repository as well as using Rbenv and RVM scripts. Choose the installation method that best suits your setup and environment.
Installing Ruby from Debian Repository
This is the easiest way to install Ruby on Debian. At the time of writing, the version in the standard Debian repository is 2.5.5.
Run the following command as root user or as a user with sudo privileges to refresh the package list and install Ruby.
After the installation is complete, verify by printing the Ruby version
The output will look like this.
Your version of Ruby may be different from the version shown above.
You have successfully installed Ruby on your Debian system and you are ready to start using it.
Installing Ruby with Rbenv
Rbenv is a lightweight Ruby version manager that allows you to easily switch Ruby versions.
We will use the
ruby-build plugin to extend the core functionality of Rbenv and allow you to install any Ruby version from source.
Start by installing git and other dependencies needed to build Ruby from source.
Run the following command to install the rbenv and ruby-build scripts.
To start using
rbenv, you need to add
If you are using Bash.
If you are using Zsh.
rbenv -v command to ensure a successful installation.
To get a list of all Ruby versions that can be installed with
For example, to install Ruby version 2.7.0 and set it as the default version, enter.
Verify that Ruby is properly installed.
Installing Ruby with RVM
RVM (Ruby Version Manager) is a command line tool that lets you install, manage and use multiple Ruby environments.
To install the dependencies required to build Ruby from source code.
Run the following command to add a GPG key and install RVM.
To get started with RVM, enter.
To get a list of all known Ruby versions, enter.
To install the latest stable version of Ruby using RVM and set it as the default version.
Verify that Ruby is correctly installed by printing the version number.
To install a specific version of Ruby, enter the following command. Replace
x.x.x with the version of Ruby you want to install.
For more information on how to use RVM to manage Ruby installations, see its documentation page.
We have shown you three ways to install Ruby on a Debian 10 server. The method you choose depends on your requirements and preferences. While it is easier to install packaged versions from the Debian repository, the Rbenv and RVM methods give you more flexibility to add and remove different Ruby versions on a per-user basis