Support Online
Skip to main content

Ruby Installation and Development Environment in Ubuntu 22.04

Meta description (155 characters): Learn how to easily install Ruby with RVM, manage dependencies, and run the “Hello World” program on Ubuntu 22.04.

🧠 What Will You Learn in This Guide?

In this guide, you will learn to install the Ruby programming language on Ubuntu 22.04 in the fastest and smoothest way. We will use the RVM (Ruby Version Manager) tool for installation. This tool allows you to easily manage different versions of Ruby and auto-install the necessary dependencies. Finally, we will write a simple Ruby program to verify that the environment is working correctly.


⚙️ Prerequisites

Before you start the installation, you need to have:

  • A virtual server (example: tr1-node01) or local computer with Ubuntu 22.04 installed.
  • sudo (administrator) privileges.
  • An active internet connection.

🔴 Installing Ruby in Ubuntu 22.04 (with RVM)

1️⃣ Installing RVM and Required Dependencies

RVM (Ruby Version Manager) automates the Ruby installation process and version management.

1.1 Import GPG Key

Add the project key to verify the reliability of RVM:

gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys \
409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB

If this command fails, try the following alternatives:

command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

💡 This process verifies the authenticity of the RVM.


Install 1.2 cURL Package

To download the RVM installation script, you need the curl tool:

sudo apt-get install curl

Characters will not appear when entering your password. This is a common security measure in the terminal.


Download 1.3 RVM Installation Script

Download the RVM installation script from the official source:

\curl -sSL https://get.rvm.io -o rvm.sh

-s silent mode, -S shows error messages, -L follows directions.


1.4 Install RVM

Install the latest stable version of RVM by running the downloaded script:

cat rvm.sh | bash -s stable

This command installs RVM on your system.

After installation, enable RVM in the current session:

source ~/.rvm/scripts/rvm

2️⃣ Installing and Verifying Ruby

Once RVM is ready, you can install Ruby and set it as the default version.

2.1 Install Ruby
rvm install ruby --default

This command downloads and installs the latest version of Ruby. If there are missing dependencies, RVM installs them automatically.

Installation may take a few minutes. When the process is completed, Ruby will be successfully installed on your system.

Check Ruby Version 2.2
ruby -v

This command shows the installed Ruby version. For example: ruby 3.2.2p20 (2025-05-10 revision 12345) [x86_64-linux]

If the rvm command is not found, close and reopen the terminal or run the following command:

source ~/.rvm/scripts/rvm

3️⃣ Test Ruby Environment (Hello World)

Let's create a simple Ruby file to see that everything is working properly.

3.1 Create New Ruby File
nano merhaba_dunya.rb
3.2 Add the Code Below
puts "Merhaba, Dünya!"
3.3 Save File and Exit

Press CTRL+X, then Y and confirm with ENTER.

3.4 Run the Program
ruby merhaba_dunya.rb

Output: Merhaba, Dünya! If you see this result, your Ruby environment has been successfully set up 🎉


🚧 Common Errors and Solutions

🛑 gpg: keyserver receive failed error: The key server may be unreachable. Alternatively import keys manually with curl (as shown above).

🛑 Cannot find command rvm: Restart the terminal session or run the command source ~/.rvm/scripts/rvm.

🛑 Installation takes too long: RVM installs dependencies such as SSL, zlib, readline, as well as Ruby. This is normal.


❓ Frequently Asked Questions (FAQ)

1. Why should RVM be preferred?

RVM prevents version conflicts and automates dependency management.

2. How can I change the Ruby version?

Install the new version with the command rvm install 3.x.x and activate it with rvm use 3.x.x.

3. Why doesn't it appear when typing a password in Bash?

Terminal hides password characters for security reasons; What you write is saved in the system.

4. Can Rails be installed after installing Ruby?

Yes, you can add the Rails framework with the command gem install rails.

5. Why were environment variables lost after installation?

Your bash profile file may not be loaded. Start a login shell with the command bash -l.


🎯 Result

Congratulations! You now have a fully functional Ruby development environment on your Ubuntu 22.04 system. Thanks to RVM, you can easily manage different Ruby versions and develop your projects safely.

💡 You can immediately distribute your Ruby applications on the GenixNode platform and benefit from the benefits of high-performance hosting.