Ruby is a highly popular, interpreted, high-level programming language. It was designed by Yukihiro “Matz” Matsumoto to prioritize programmer productivity and fun. Ruby offers a simple syntax that’s natural to read and easy to write. In this tutorial, we’ll demonstrate how to install Ruby 3.2 on CentOS or Red Hat Enterprise Linux (RHEL) using the Ruby Version Manager (RVM).
RVM is a command-line tool that allows you to easily install, manage, and work with multiple ruby environments. It gives you flexibility concerning the version of Ruby you want to use in your system and helps in managing/gem dependencies. In this article, we’ll walk you through installing Ruby 3.2 using RVM on CentOS/RHEL.
Please note that this guide assumes that you are working with a non-root user with sudo privileges configured on your system.
Step 1: Update Your System
Before we start, it’s always a good idea to update your system packages to the latest versions. You can do this by running the following command:
sudo yum update -y
Step 2: Install Dependencies
The next step is to install some dependencies required for RVM. Run the following command to do this:
sudo yum install curl gpg gcc gcc-c++ make libyaml-devel openssl-devel readline-devel zlib-devel -y
Step 3: Install RVM
Now we’re ready to install RVM. Here’s the command to do that:
curl -sSL https://get.rvm.io | bash -s stable
This command fetches a script from the RVM website and runs it. The stable flag tells the script to install the latest stable version of RVM.
After installing RVM, you need to set up the RVM environment using the following command:
source ~/.rvm/scripts/rvm
To ensure that RVM is installed, you can check its version with:
rvm --version
Step 4: Install Ruby
With RVM installed, we can now install Ruby. The following command will install Ruby 3.2:
rvm install 3.2
This might take a while, as RVM will download the Ruby source code and compile it.
After the installation, you can set Ruby 3.2 as the default version with:
rvm use 3.2 --default
You can verify that Ruby was installed correctly with:
ruby --version
This should output something like ruby 3.2.0.
Step 5: Install Bundler
The last step is to install Bundler, a Ruby gem that manages your project dependencies. This can be achieved with the following command:
gem install bundler
You can check the version of Bundler that was installed with:
bundler --version
Conclusion
You have now successfully installed Ruby 3.2 on your CentOS/RHEL system using RVM. Now, you’re ready to start developing your Ruby application with the benefits of RVM for managing your Ruby environment.
Keep in mind that you can install different versions of Ruby and switch between them using the rvm use command, which can be especially helpful when you’re working on multiple projects that require different Ruby versions. Also, remember that any new terminal sessions will not have RVM loaded by default. To have it loaded automatically, you may need to add `source ~/.rvm/scripts/rvm` to your shell profile
1 Comment
Thanks a million! This saved my day