How to Install Latest Version of Ruby on Debian 12
Ruby is an interpreted, high-level, general-purpose programming language. It was designed with an emphasis on programming productivity and simplicity. In Ruby, everything is an object, including primitive data types, we will walk you through the process of installing Ruby on Debian 12 using RVM (Ruby Version Manager) and configuring a robust programming environment.
Prerequisites
Before diving into the installation process, ensure the following prerequisites are met:
-
A Debian 12 server instance
- User account with root privileges
Let's get started!
Update System Packages
Ensure your system packages are up-to-date by running,
apt update
apt upgrade
Install Required Dependencies
Before installing RVM, install the necessary dependencies,
apt install curl g++ gcc gnupg autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev libssl-dev
Confirm the installation when prompted.
Installing RVM
RVM (Ruby Version Manager) is a command-line tool which allows you to easily install, manage with multiple ruby environments from interpreters to sets of gems.
Retrieve the latest RVM releases and install using the following commands,
gpg --keyserver keys.openpgp.org --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Output:
root@vps:~# gpg --keyserver keys.openpgp.org --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 105BD0E739499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: key 3804BB82D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: Total number processed: 2
gpg: imported: 2
root@vps:~#
Install the RVM using below command,
curl -sSL https://get.rvm.io | bash -s stable
Output:
root@vps:~# curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made Fri 15 Jan 2021 06:46:22 PM UTC
gpg: using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB
GPG verified '/usr/local/rvm/archives/rvm-1.29.12.tgz'
Activate RVM by loading it into the shell using below command,
source /etc/profile.d/rvm.sh
Installing Ruby
Install Ruby version 3.2.3 via RVM or verify the most recent release, please refer to the official page located at Official Page.
rvm install ruby 3.2.3
Output:
root@vps:~# rvm install ruby 3.2.3
Searching for binary rubies, this might take some time.
No binary rubies available for: debian/11/x86_64/ruby-3.2.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for debian.
Installing requirements for debian.
Updating system..
Installing required packages: patch, gawk, patch...
Requirements installation successful.
...
Setting Default Ruby Version using below command,
rvm --default use ruby 3.2.3
Verify Ruby Version
Verify that Ruby is installed correctly,
ruby --version
Output:
root@vps:~# ruby --version
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux]
root@vps:~#
Upgrade to the Latest Ruby Version
Please ensure to verify the current Ruby version on the Official Page. As of creating this wiki, the latest version is 3.3.0. Kindly update the version accordingly,
rvm install ruby 3.3.0
Set/update the latest version with default version,
rvm --default use ruby 3.3.0
Output:
root@vps:~# rvm --default use ruby 3.3.0
Using /usr/local/rvm/gems/ruby-3.3.0
root@vps:~#
Verify the version using below command,
ruby --version
Output:
root@vps:~# ruby --version
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
root@vps:~#
Test the Ruby Environment
Create a simple Ruby program,
nano program.rb
Enter the following lines,
puts "My First Program"
Save the file and exit the editor.
Now, Run the program using below command,
ruby program.rb
Output:
root@vps:~# ruby program.rb
My First Program
root@vps:~#
You have successfully installed Ruby Latest Version using RVM on your Debian 12 server and configured a programming environment.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS