Skip to content

How To Install Ruby Lang on Debian Linux

This article will help you to install ruby on rails on Debian using RVM. RVM is the Ruby Version Manager helps for installing and managing Ruby

Steps
7
Category
Programming
Covers
Debian, Ruby
Versions & support
About Ruby →, About Debian →
On this page 7 steps

Ruby is a popular programming language among a large number of developers. Rails are the framework to run ruby language. Ruby language was created by Yukihiro “Matz” Matsumoto and first published in 1995. This article will help you to install ruby on rails on Debian Linux systems using RVM. RVM is the Ruby Version Manager helps for installing and managing Ruby language similar to NVM for Node.js.

Step 1 of 7Prerequisites

Login to your Debian system using GUI or use ssh for remote hosts. Then install some pre-required packages.

sudo apt update 
sudo apt install curl gnupg2 

Step 2 of 7Install RVM

Before installing RVM first we need to import public key in our system then use curl to install rvm in our system.

curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import - 
curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import - 
curl -sSL https://get.rvm.io | sudo bash -s stable 

After installing RVM first we need to set up rvm environment using below command. so that current shell takes new environment settings.

source /etc/profile.d/rvm.sh 

After this, install all the dependencies for installing Ruby automatically on the system. Run below command on terminal.

rvm requirements 

Step 3 of 7List Available Ruby Versions

Get a list of available versions of Ruby language. You can install any version of your choice or requirements showing on the list.

rvm list known 
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.10]
[ruby-]2.5[.8]
[ruby-]2.6[.6]
[ruby-]2.7[.2]
[ruby-]3[.0.0]
ruby-head

Step 4 of 7Install Ruby on Debian

RVM is useful for installation of multiple Ruby versions on the single system. Use the following command to install required Ruby on your system. As shown below example will install latest Ruby version on Debian system.

rvm install ruby 

Step 5 of 7Setup Default Ruby Version

Use rvm command to set up default ruby version to be used by applications. You can install multiple versions as defined in the above step. Now select which version you want to use.

rvm use 3.0 --default 

Using /usr/local/rvm/gems/ruby-3.0.0

Step 6 of 7Check Ruby Version

Using following command you can check the current ruby version is used.

ruby --version  

ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

Step 7 of 7Install Rails

You can install the latest stable release version of Rails by running the following command. It will install Rails in global gemset So that all applications share the same version of Rails.

gem install rails 
rails -v 

Or we can get a specific version of Rails by defining --version during installation. Visit here to get available rails versions.

gem install rails --version=5.2.3 

Congratulation’s, You have successfully installed Ruby on your system. Read our next articles to deploy Ruby with Apache or Ruby with Nginx web server with simple steps.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

3 Comments

  1. I cannot thank you enough for this. I had just purchased a Raspberry PI for Octoprint, but hadn’t yet installed the BLTouch I’d had. I found a good description on how to install the bootloader WITHOUT an Arduino, just using the RaspPi.

    It used Homebrew. Homebrew wouldn’t install without Ruby, and specifically Ruby 2.6. Inside Homebrew, they said to use rbenv/ruby-build which fought me every step of the way, refusing to install 2.6 (just stalled).

    I have been fighting with this for TWO DAYS. You’re a lifesaver!

Leave a Reply

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


Back to top