Table of Contents
This guide is about Guide: Install RVM- Ruby Version Manager on Ubuntu 20.04 LTS. So read this free guide, Guide: Install RVM- Ruby Version Manager on Ubuntu 20.04 LTS step by step. If you have query related to same article you may contact us.
Guide: Install RVM- Ruby Version Manager on Ubuntu 20.04 LTS – Guide
Ruby is an open-source, object-oriented, general-purpose programming language that has recently gained prominence as the de facto tool for building web applications.
You are probably familiar with Ruby. In fact, even individuals who have nothing to do with programming, sooner or later, have come across this programming language. Also, this shouldn’t shock anyone; Ruby is an extraordinarily vigorous language with understandable sentence structure. Ruby is used in many technology industries. Perhaps the best effect of Ruby is the ‘Ruby on Rails’ framework, on which several well-known sites are built, for example, twitter.com, airbnb.com, groupon.com and github.com.
Installing Ruby from Ubuntu # repositories
The easiest way to install Ruby on Ubuntu is using the apt package manager. As of this writing, the version in the Ubuntu repositories is 2.7.0, which is not always the latest stable release.
Installation is pretty straight forward. Run the following commands as root or user with sudo privileges to update the package index and install Ruby:
$ sudo apt update $ sudo apt install ruby-full $ ruby –version
The output will look like this:
$ ruby 2.7.0p0 (revision 647ee6f091 of 12/25/2019) [x86_64-linux-gnu]
Your Ruby version may differ from the one shown above. That’s it! You have successfully installed Ruby on your Ubuntu machine and can start using it.
Installing Ruby Using Rbenv
Rbenv is a lightweight command-line tool that lets you easily switch Ruby versions.
By default, rbenv does not control Ruby installation. We will use ruby-build to install Ruby. It is available as a standalone program and as a plugin for rbenv. The ruby-build script installs Ruby from source. In order to build Ruby, install the necessary libraries and compilers:
$ sudo apt update sudo apt install git curl autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev
The simplest way to install the rbenv tool is to use the installation shell script. Run the following curl or download and run the script:
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash
The script clones the rbenv and ruby-build repositories from GitHub to the ~ / .rbenv directory. The installer script also calls another script that checks the installation. The output from the script will look like below:
Running doctor script to verify installation … Checking for `rbenv ‘in PATH: not found You seem to have rbenv installed in` /home/vagrant/.rbenv/bin ‘, but that directory is not present in the PATH. Add it to the PATH by setting `~ / .bashrc ‘,` ~ / .zshrc’ or `~ / .config / fish / config.fish ‘.
To start using rbenv, you need to add $ HOME / .rbenv / bin to your PATH. If you are using Bash:
$ echo ‘export PATH = “$ HOME / .rbenv / bin: $PATH”‘ >> ~ / .bashrc $ echo ‘eval “$ (rbenv init -)”‘ >> ~ / .bashrc $ source ~ / .bashrc
If you are using Zsh:
$ echo ‘export PATH = “$ HOME / .rbenv / bin: $ PATH”‘ >> ~ / .zshrc $ echo ‘eval “$ (rbenv init -)”‘ >> ~ / .zshrc $ source ~ / .zshrc
Run the rbenv -v command to ensure the installation was successful:
$ rbenv -v $ rbenv 1.1.2-30-gc879cb0
For a list of all Ruby versions that can be installed with rbenv, type:
$ rbenv install -l
For example, to install Ruby version 2.7.1 and set it to a global version, you would type:
$ rbenv install 2.7.1 $ rbenv global 2.7.1
Rbenv works by putting a directory called shims in front of your PATH. This directory contains scripts (shims) whose job is to intercept Ruby commands and execute the corresponding binaries. Rbenv allows you to set the Ruby shell version, local and global:
Do not use sudo to install gems when Ruby is managed with rbenv. Each Ruby version is installed in the ~ / .rbenv / versions directory and can be written by the user.
Installing Ruby Using RVM #
RVM is a command-line tool you can use to install, manage, and work with various Ruby environments. Install the necessary dependencies to create Ruby from source:
$ sudo apt update sudo apt install curl g ++ gcc autoconf automake bison libc6-dev libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev libline -dev libssl-dev
$ gpg –keyserver hkp: //keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB $ curl -sSL https://get.rvm | bash -s stable
To start using RVM, load the script’s environment variables using the source command:
$ source ~ / .rvm / scripts / rvm
For a list of all Ruby versions that can be installed with this tool, type:
known $rvm list
Install the latest stable version of Ruby with RVM and set it as the default version:
$ rvm install ruby $ rvm – default use ruby
Check that Ruby has been installed correctly by printing the version number:
$ruby -v
ruby 2.7.0p0 (revision 647ee6f091 of 12/25/2019) [x86_64-linux]
If you want to install a specific version of Ruby, enter the commands below. Replace xxx with the Ruby version you want to install.
Final note
I hope you like the guide Guide: Install RVM- Ruby Version Manager on Ubuntu 20.04 LTS. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.