How to install Ruby on Rails with RVM on Ubuntu 22.04 Terminal?

By Hardik Savani May 1, 2024 Category : Ubuntu

Hi Friends,

This post will give you an example of how to install ruby on rails on ubuntu 22.04. you can understand a concept of how to install ruby on rails with rvm on ubuntu 22.04. I’m going to show you about how to install ruby on rails in ubuntu 22.04. I explained simply step by step ubuntu 22.04 install ruby on rails steps. Alright, let us dive into the details.

Sure, here's a step-by-step guide to installing Ruby on Rails with RVM (Ruby Version Manager) on Ubuntu 22.04:

Step 1: Update Your System

Open a terminal and update your package lists to ensure you have the latest information about available packages:

sudo apt update

Step 2: Install Required Dependencies

Install the necessary dependencies for building Ruby and Rails:

sudo apt install -y curl gpg gcc g++ make libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev sqlite3

Step 3: Install RVM (Ruby Version Manager)

Install RVM using curl:

\curl -sSL | bash -s stable

After the installation is complete, you may need to load RVM into your current shell session or restart your terminal:

source ~/.rvm/scripts/rvm

Step 4: Install Ruby

Now that RVM is installed, you can install Ruby. To install a specific version of Ruby (e.g., Ruby 3.0.2), use the following command:

rvm install 3.0.2

Set Ruby 3.0.2 as the default version:

rvm use 3.0.2 --default

Step 5: Install Node.js

Rails requires a JavaScript runtime like Node.js. You can install it using the NodeSource repository:

curl -fsSL | sudo -E bash -

sudo apt install -y nodejs

Step 6: Install Yarn

Yarn is another package manager required by some Rails applications. You can install it with the following commands:

curl -sS | sudo gpg --dearmor -o /usr/share/keyrings/yarn-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/yarn-archive-keyring.gpg] stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt update

sudo apt install yarn

Step 7: Install Rails

Now that you have Ruby, Node.js, and Yarn installed, you can install Ruby on Rails using the gem package manager:

gem install rails

Step 8: Verify Installation

To verify that Ruby on Rails is installed correctly, check the versions of Ruby and Rails:

ruby -v

rails -v

You should see the versions of Ruby and Rails displayed in the terminal.

That's it! You've successfully installed Ruby on Rails with RVM on Ubuntu 22.04. You're now ready to start developing Ruby on Rails applications on your system.

Tags :