Ruby is a popular programming language that is used to develop web applications, mobile applications, and desktop applications. If you are a Fedora user, you may want to install Ruby on your system to start developing Ruby-based applications. In this article, we will guide you through the process of installing Ruby on Fedora using RVM (Ruby Version Manager).
RVM is a popular tool for managing Ruby environments on Linux systems. With RVM, you can easily install multiple Ruby versions on your system, switch between them, and manage gemsets.
Here are the steps to install Ruby on Fedora using RVM:
Step 1: Install Required Dependencies
Before you can install RVM and Ruby on your Fedora system, you need to install some dependencies. Open the terminal and run the following command to install the required packages:
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
Now that you have installed the required dependencies, you can proceed to install RVM.
curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import -
RVM can be installed using the following command:
curl -L get.rvm.io | sudo bash -s stable
Also, run the below command to load the RVM environment.
source /etc/profile.d/rvm.sh
rvm reload
Step 3: Verify Dependencies
Now use the following command to verify all dependencies are properly installed.
rvm requirements run
Checking requirements for fedora.
Requirements installation successful.
Step 4: Install Ruby on Fedora
With RVM installed and configured, you can now install Ruby. To install the latest stable version of Ruby, run the following command:
rvm install ruby --default
This will install the latest stable version of Ruby and set it as the default version. You can also install a specific version of Ruby by specifying the version number in the command, for example:
rvm install 2.7.2
This will install Ruby version 2.7.2.
Step 5: Verify Ruby Installation
After installing Ruby, you can verify the installation by running the following command:
ruby -v
This should display the version of Ruby that you have installed.
Step 6: Install Bundler
Bundler is a popular Ruby gem that is used to manage application dependencies. You can install Bundler using the following command:
gem install bundler
Step 7: Create and Use Gemsets
A gemset is a separate environment for your Ruby applications, where you can install gems and manage their dependencies. You can create a gemset for your application using the following command:
rvm gemset create myapp
This will create a new gemset named “myapp”.
Once you have created a gemset, you can switch to it using the following command:
rvm gemset use ruby@myapp
This will switch to the “myapp” gemset. You can now install gems and manage their dependencies in this gemset.
Step 8: Change Default Ruby Version
To change the default Ruby version using RVM (Ruby Version Manager), you can follow these steps:
- First, make sure that you have installed the desired version of Ruby using RVM. You can check this by running the command rvm list.
rvm list
- To set a new default Ruby version, use the following command:
rvm --default use <ruby_version>
Replace <ruby_version> with the version number or name of the Ruby version that you want to use as default.
- To verify that the default version has been changed, run “ruby -v”. This should show the version number of the new default Ruby version.
- You can also set a default gemset for the new default Ruby version by running the following command:
rvm gemset use <gemset_name> --default
Replace <gemset_name> with the name of the gemset that you want to use as default.
That’s it! You have successfully changed the default Ruby version using RVM.
Conclusion
In this article, we have shown you how to install Ruby on Fedora using RVM. With RVM, you can easily manage multiple Ruby versions and gemsets on your system. Now that you have Ruby installed, you can start developing Ruby-based applications on your Fedora system.
Read our next article to integrate Ruby with Apache web server with easy steps.
References:
1. http://rvm.io/rubies/installing
7 Comments
Doing “sudo -i” at the begginig is a terrible idea. In worst case scenario it may render using some of the tools absolutly impossible (it will be impossible to use “gem install” for example), and the mess it creates is very difficult to fix.
So this will install rvm and ruby on your system all right. But it will be useless for most of the part, and it will create a major mess on your system.
Don’t use sudo -i, instead use sudo where you actually need it.
Thanks Sebastian, You are write, tutorial has been updated accordingly
Fedora 33
$ sudo rvm install 2.7
sudo: rvm: command not found
is it gpg2 instead of gpg3?
Thanks Bumbaa, Article has been updated.
Thanks dear for help really helpful .
Good tutorial. Just a quick correction; you have “rvm install 2.3.3,” but I’m sure you meant “rvm install 2.3.5.” Keep up the good work!