In this blog post, we will guide you through the process of installing Ruby on your Ubuntu system. Ruby is a powerful and versatile programming language, popular for its use in web development and scripting.
Step 1: Update and Upgrade Your System
Before starting the installation, it is always a good idea to update and upgrade your system packages. This will ensure that you have the latest versions of software and any security patches. To do this, open your terminal and type the following command:
sudo apt-get update && sudo apt-get upgrade
Step 2: Install Ruby using APT Package Manager
Now that your system is up-to-date, you can install Ruby using the APT package manager. This method is more straightforward, but it may not give you the latest version of Ruby. To install Ruby, type the following command in your terminal:
sudo apt-get install ruby-full
This will install the latest version of Ruby available in the Ubuntu repository.
Step 3: Install Ruby using RVM (Recommended)
If you want to have more control over the Ruby version and easily switch between different versions, it is recommended to use the Ruby Version Manager (RVM). First, you need to install the RVM dependencies by running the following command:
sudo apt-get install curl g++ gcc 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
Next, install RVM by running this command:
curl -sSL https://get.rvm.io | bash -s stable
Once the installation is complete, load RVM:
Now, you can install any version of Ruby you need using RVM. For example, to install the latest version, run:
rvm install ruby --default
Step 4: Verify the Installation
To check if Ruby was installed successfully and confirm the version, run the following command:
It should display the installed version of Ruby, like this:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
If you see the Ruby version, it means Ruby has been installed successfully on your Ubuntu system.
In this blog post, we have shown you how to install Ruby on your Ubuntu system using two different methods: APT package manager and RVM. The choice depends on your preference, but using RVM is recommended for better control over different Ruby versions. Now you can start exploring and developing with Ruby!