Saturday , July 20 2019
Home / Uncategorized / How to install Ruby on Debian 9

How to install Ruby on Debian 9



This tutorial will guide you through the steps of installing Ruby on a Debian 9 system. Today, Ruby is one of the most popular languages. It has an elegant syntax and is the language behind the powerful Ruby on Rails framework.

There are several ways to install Ruby on Debian. In the following sections, we will show you how to install Ruby using the Rbenv and RVM script and the default Debian repositories.

Prerequisites

Before starting the tutorial, make sure you have logged in as user with sudo privileges.

Method 1: Install Ruby from the Debian repositories

The easiest way to install Ruby on your Debian system is through the suitable package manager. At the time of writing this document, the version included in the Debian repositories is 2.3.3 which will soon be created soon.

  1. First, update the package list with:

  2. Install the ruby-full package by running the following command:

  3. Once the installation is complete, you can verify that it has succeeded by printing the version of Ruby:

    The output will be similar to this:

Method 2: Install Ruby using Rbenv

Rbenv is a lightweight Ruby version management tool that allows you to easily change Ruby versions.

By default, Rbenv does not manage the installation of Ruby versions. ruby-build is a tool that helps you install any version of Ruby that you might need. It is available as a standalone program and as a plugin for rbenv.

  1. Install the dependencies required for the ruby-build tool to create Ruby from the source:

  2. Then, run the following command to install both the rbenv and ruby-build scripts:

    In case of successful installation, the script will print something like this:

  3. Before we start using rbenv, we must add $ HOME / .rbenv / bin to our PATH.

    If you use Bash, type:

    If you're using the Zsh type:

  4. Now that rbenv is installed on our system we can easily install the latest stable version of Ruby and set it as the default version with:

    Verify that Ruby has been installed correctly by printing the version number:

Advertisement

Method 3: Install Ruby using RVM

RVM is another tool to install, manage and work with multiple Ruby environments.

  1. First, install the required dependencies for the RVM utility to create Ruby from the source:

  2. Then, run the following commands to add the GPG key and install RVM:

    In case of successful installation, the script will print something like this:

  3. To start using RVM you need to run the following command:

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

    Verify that Ruby has been installed correctly by printing the version number:

    ruby -v
    

For more information on how to manage your Ruby installations, visit the RVM Documentation page.

Conclusion

We've shown you three different ways to install Ruby on your Debian 9 server. The method you choose depends on your needs and preferences. Although the installation of the version packaged by the Debian repository is simpler, the Rbenv and RVM methods offer more flexibility for adding and removing different versions of Ruby per user.

If you have any questions or comments, feel free to comment below.


Source link

Leave a Reply

Your email address will not be published.