Guide: Install RVM-Ruby Version Manager on Ubuntu 20.04 LTS


This tutorial is about Guide: Install RVM-Ruby Version Manager on Ubuntu 20.04 LTS. We will do our best to make sure you understand this guide. I hope you will like this blog Guide: Install RVM-Ruby Version Manager on Ubuntu 20.04 LTS. If your answer is yes, please share after reading this.

Verification Guide: Install RVM-Ruby Version Manager on Ubuntu 20.04 LTS

Ruby is an open-source, general-purpose, object-oriented programming language that has recently gained prominence as a de facto tool for building web applications.

Chances are you already know Ruby. In fact, even people who have nothing to do with programming sooner or later got to know this programming language. Moreover, this should not surprise anyone; Ruby is an extraordinarily vigorous language with a somewhat understandable sentence structure. Ruby is used in many technology industries. Perhaps the best effect of Ruby is the “Ruby on Rails” framework, which creates many popular sites, 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 to use the apt package manager. At the time of writing this article, the version in the Ubuntu repositories is 2.7.0, which may not always be the latest stable version.

The installation is pretty straightforward. Run the following commands as root or a 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 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]

Your version of Ruby may differ from the one pictured above. That’s all! You have successfully installed Ruby on your Ubuntu machine and you can start using it.

Installing Ruby with Rbenv

Rbenv is a lightweight command line tool that allows you to easily change versions of Ruby.

By default, rbenv does not handle the installation of Ruby. We will use ruby-build to install Ruby. It is available as a stand-alone program and as an add-on to rbenv. The ruby-build script installs Ruby from source. In order to compile Ruby, install the required 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 easiest 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 | has tried

The script clones the rbenv and ruby-build repositories from GitHub to the ~ / .rbenv directory. The installation script also calls another script that verifies the installation. The output of the script will look like this:

Running the doctor script to verify the installation … Searching for `rbenv ‘in PATH: not found You seem to have installed rbenv in` /home/vagrant/.rbenv/bin’, but this directory is not present in PATH. Add it to PATH by defining your `~ / .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 make sure the installation was successful:

$ rbenv -v $ rbenv 1.1.2-30-gc879cb0

For a list of all versions of Ruby that can be installed with rbenv, type:

$ rbenv install -l

For example, to install Ruby version 2.7.1 and configure it as a global version, you must type:

$ rbenv install 2.7.1 $ rbenv global 2.7.1

Rbenv works by inserting 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 configure the shell, local and global version of Ruby:

  • The shell version is used in the current shell and has the highest priority. It can be set by setting the RBENV_VERSION environment variable using the rbenv shell command . The local version is configured by directory. This version is written to the .ruby-version file. When you run a Ruby script, rbenv searches for the file in the current directory and in all parent directories. Use the version of Ruby stored in the first file found. To configure a local version, go to the directory and run the command rbenv local . The global version is used by all shells when no shell or local version is configured. Use rbenv global to define a global version.

Do not use sudo to install gems when Ruby is managed with rbenv. Each version of Ruby is installed in the ~ / .rbenv / versions directory and can be written by the user.

Installing Ruby using RVM #

RVM is a command line tool that you can use to install, manage, and work with multiple Ruby environments. Install the dependencies needed to compile 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 libreadline-dev libssl developer

$ gpg –keyserver hkp: //keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB $ curl -sSvLm. bash -s stable

To start using RVM, load the environment variables from the script with the source command:

$ source ~ / .rvm / scripts / rvm

For a list of all versions of Ruby that can be installed with this tool, type:

$ rvm known list

Install the latest stable version of Ruby with RVM and set it as the default version:

$ rvm install ruby ​​$ rvm – default use ruby

Verify that Ruby was installed correctly by printing the version number:

$ ruby ​​-v

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

If you want to install a specific version of Ruby, enter the following commands. Replace xxx with the version of Ruby you want to install.

Final words: Guide: Install RVM-Ruby Version Manager on Ubuntu 20.04 LTS

hope you will understand this item Guide: Install RVM-Ruby Version Manager on Ubuntu 20.04 LTS, if your answer is no, you can request anything through the contact forum section linked to this article. And if your answer is yes, then share this article with your family and friends.



Comments are closed.