Advance

Tutorial Setup Ruby with RVM on Ubuntu 20.04

Tutorial Setup Ruby with RVM on Ubuntu 20.04
0
(0)

If you need to work with different versions of Ruby for different projects, RVM is useful for you. RVM makes it easy to manage multiple versions of Ruby on the same machine. This article will teach you How to Setup Ruby with RVM on Ubuntu 20.04. If you intend to buy an Ubuntu VPS server, you can check out the packages offered on the Eldernode website.

How to Install Ruby with RVM on Ubuntu Server

RVM stands for Ruby Version Manager and is an open-source command-line tool that allows you to manage multiple versions of Ruby on the same machine. you can easily switch between different versions of Ruby depending on your needs using RVM. This project is actively maintained and supported by a community of developers and is available for Linux and macOS operating systems.

Recommended Article: How to secure Nginx web server with Let’s Encrypt on Debian 10

Setting Up Ruby with RVM on Ubuntu 20.04

To setup Ruby with RVM on Ubuntu 20.04, follow the steps below.

Firstly, update your Ubuntu packages using the following command:

sudo apt update
sudo apt upgrade

And install GPG (GNU Privacy Guard) with the following command:

sudo apt install gnupg2

Request the RVM project’s public key to verify the legitimacy of your download as shown below:

gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Now it’s time to download the RVM installation script from the project’s website by running the following command:

\curl -sSL https://get.rvm.io -o rvm.sh

Once the download is completed, you can audit the contents of the script before applying it using the command below:

nano rvm.sh

Hit CTRL-X to close out the nano text editor.

If you pipe it to bash, you can install the latest stable Rails version which will also pull in the associated latest stable release of Ruby:

cat rvm.sh | bash -s stable --rails

Now source the RVM scripts from the directory they were installed as shown below:

source ~/.rvm/scripts/rvm

You can use RVM to install a specific version of Ruby for your application. To do this, first list the Ruby versions with the following command:

rvm list known

To install a specific version through Ruby, run the following command:

rvm install 3.0.0

Replace the version number with your version of choice.

If you want to list the available Ruby versions you have installed, run the command below:

rvm list

To switch between the Ruby versions, use the following command:

rvm use 3.0.0

Rails is a gem and also is a standardized format that contains Ruby programs. To install various versions of Rails, first list the valid versions of Rails as shown below:

gem search '^rails$' --all

And install your required version of Rails by running the following command:

gem install rails -v 7.0.2

Replace the version number with your desired version.

Create gemsets and then install Rails in those using the regular gem commands, to use different versions of Rails with each ruby.

You can create a gemset using the command below:

rvm gemset create gemset_name

Run the following command to specify a Ruby version to use when creating a gemset:

rvm 3.0.0@gemset_name --create

You can have self-contained environments for gems, as well as multiple environments for each version of Ruby you install using gemsets.

That’s it!

Recommended Article: How To Install Composer on Debian 10 with 5 Step [complete]

Conclusion

RVM is a command line tool that allows you to manage and work with multiple Ruby development environments. In this article, we taught you how to set up Ruby with RVM on Ubuntu 20.04. I hope you found this tutorial useful and that it helps you to set up Ruby with RVM on your Ubuntu server. If you have any questions or problems with the installation process, you can contact us in the Comments section.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day