Need to install ruby on rails with rvm on Ubuntu 22.04, Just open the terminal window and type rvm install ruby --latest
command into it to install ruby and type gem install rails
command into it to install rails with rvm.
How to Install Ruby on Rails with RVM on Ubuntu 22.04
Steps to install and uninstall ruby on rails with rvm on Linux ubuntu 22.04 using terminal:
Step 1 – Update System Dependencies
Press ctrl+alt+t on the keyboard to start a terminal window, and type the sudo apt update
command in it to update system dependencies:
sudo apt update
Step 2 – Install Bundler
Ruby has some dependencies or packages, so you can use the sudo apt install curl gpg2 gcc make libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev
command to install them, type the command in the terminal window like this:
sudo apt install curl gpg2 gcc make libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev
Step 3 – Install RVM
RVM is a package manager for Ruby, so to install it you need to use \curl -sSL https://get.rvm.io | bash -s stable
command:
\curl -sSL https://get.rvm.io | bash -s stable
After installation, you need to load the RVM scripts or restart your terminal to use RVM:
source ~/.rvm/scripts/rvm
Step 4 – Install Ruby
To install the stable or latest version of Ruby, you can use rvm install ruby --latest
command at the command line:
rvm install ruby --latest
After the installation is complete, set the installed Ruby version as the default:
rvm use ruby --default
Step 5 – Install Node.js
Rails requires a JavaScript runtime for some of its features. Install Node.js using NodeSource’s PPA:
curl -sL https://deb.nodesource.com/setup_21.x | sudo -E bash - sudo apt install -y nodejs
Next, Yarn is a package manager for JavaScript used by Rails. Install it using npm (which comes with Node.js):
sudo npm install -g yarn
Step 6 – Install Rails
With Ruby and the required dependencies in place, you can install Ruby on Rails using the gem package manager:
gem install rails
Step 7 – Verify Installation
Confirm that Ruby and Rails have been installed successfully:
ruby --version
Step 8 – Uninstall Ruby on Ubuntu
If for any reason you want to completely uninstall or delete Ruby from your Ubuntu system, you can use sudo apt remove --autoremove ruby
command for that:
sudo apt remove --autoremove ruby
Conclusion
Congratulations! You’ve successfully installed Ruby on Rails using RVM on your Ubuntu system. You can now start creating and working on Ruby on Rails applications.