You are probably already familiar with Ruby. Even those who have nothing to do with software have, at some point, heard of this programming language. And that should come as no surprise; Ruby is an incredibly robust language with relatively comprehendible sentence structure. Ruby is used in many tech industries. Perhaps the greatest impact of Ruby is the ‘Ruby on Rails’ framework, upon which many famous websites are built, such as twitter.com, airbnb.com, groupon.com, and github.com.
This article will demonstrate two different ways to get Ruby up and running on your system.
- Using Ubuntu’s official repositories
- Using Ruby Environmental Manager, or RVM
Method 1: From Ubuntu’s Official Repositories
To install Ruby on Ubuntu, our recommendation to download it from the standard Ubuntu repositories, as this is relatively simpler than any other method. This method uses the apt package manager.
Step 1: Update the Package Index
Start by updating the package index. To do so, enter the command below:
Step 2: Install Ruby
Enter the following command to install Ruby:
The above command should install Ruby on your system. All that is left now is to check if the latest version was downloaded.
Step 3: Verify the Install
Sometimes, the most stable version is not installed. To make sure that this is not the case, type in the following command:
This will print the version of Ruby you installed in Step 2. The latest version, as of uploading this tutorial, is v2.7. 1, which could be updated again by the time you install Ruby on your system.
With your install verified, you can finally start using Ruby. If the version was not up-to-date, try the second method.
Method 2: Installing with Ruby Environmental Manager (RVM)
This method involves a command-line tool called Ruby Environmental Manager, or RVM. Using this tool would be preferable if you are working on several Ruby environments at once, as this allows you to manage Ruby on any Linux system.
Step 1: Install Related Dependencies
First, install the related dependencies. Use the following commands to do so:
\libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool
\libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev
\libreadline-dev libssl-dev
Step 2: Install Ruby Environment Manager
To install RVM, you will need to add the GPG key first. Enter the following command to do so:
409B6B1796C275462A1703113804BB82D39DC0E3
7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Then, install RVM by entering the following:
Step 3: Check for Latest Ruby Version
Enter the following to open the script environment variables and summon a list of Ruby versions compatible with your system:
Step 4: Install Ruby
Now, you just need to pick a version to install. You should install the latest version available. Enter the following command to install Ruby:
To set this version of Ruby as the default version, type:
If you do not wish to install the latest version, then you must specify which version you would like to install.
For example, if you are downloading version 2.2.7, then you must modify the command as follows:
$ rvm --default use ruby-2.2.7
You have now successfully installed Ruby on your Ubuntu 20.04 system.
To print out the version number, type in the following:
This should verify the version installed on your system.
In Summary
Ruby is a great language that balances the key components of functional and imperative programming, making it an incredibly versatile programming tool and a great place to start learning how to code.
This article discussed two methods to install Ruby. Downloading and installing Ruby directly from the Ubuntu repositories is the simplest and quickest way to go. However, using RVM comes with the additional benefit of managing the different versions to install and update.
from Linux Hint https://ift.tt/2EBBgMP
0 Comments