How to Install Ruby on Fedora using RVM. Ruby is a dynamic, object-oriented programming language. We are using RVM, which stands for Ruby Version Manager, which makes it easier to install Ruby on the Linux platform. RVM is also helpful for managing multiple versions of Ruby without conflict, and we can switch the system to any version of Ruby using a single command.
This tutorial will help you to install the Ruby stable release on your Fedora systems using RVM.
Step 1 – Prerequisites
First of all, we need to install all required packages for ruby installation on our system using the following command. Login to your Fedora system and open the terminal.
sudo dnf install gcc-c++ patch readline readline-devel zlib zlib-devel \ libyaml-devel libffi-devel openssl-devel make \ bzip2 autoconf automake libtool bison sqlite-devel
Step 2 – Install RVM
Then, install the latest stable version of RVM on your system using the following command. This command will automatically download all required files and install them on your system.
curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import -
curl -L get.rvm.io | sudo bash -s stable
Also, run the below command to load the RVM environment.
Step 3 – Verify Dependencies
Now use the following command to verify all dependencies are properly installed.
rvm requirements runChecking requirements for fedora. Requirements installation successful.
Step 4 – Install Ruby on Fedora
Now, your system is ready for the Ruby installation. You can find the available Ruby version for installation using the below command.
rvm list known
Then install the required Ruby version on your system. Here, I am installing Ruby 2.7 on my Fedora 35 system. You can simply replace the version with the below command of your choice and install it.
sudo rvm install 2.7
Step 5 – Setup Default Ruby Version
First of all, check the currently installed ruby versions on your system.
rvm listruby-2.4.4 [ x86_64 ] * ruby-2.5.1 [ x86_64 ] => ruby-2.7.0 [ x86_64 ] # => - current # =* - current && default # * - default
After that use rvm command to set up the default ruby version to be used by applications.
sudo rvm use 2.7 --defaultUsing /usr/local/rvm/gems/ruby-2.7.2
Step 6 – Check Current Ruby Version.
Using the following command you can check the current ruby version is used.
ruby --versionruby 2.7.2p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
Congratulations, Finally you have successfully installed Ruby on your system. Read our next article to integrate Ruby with Apache web server with easy steps.