Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

setup ruby and rbenv

Joseph Cayouette edited this page Aug 8, 2019 · 9 revisions

Setup Ruby and rbenv

If you would like to use the full capabilities of our toolchain you need to install and configure Ruby. The easiest way to get Ruby up and running is to follow our rbenv guide. Using rbenv will allow you to easily manage multiple ruby versions and gems(Ruby software packages) without affecting your system libraries.

This guide has been adapted from How To Install Ruby on Rails with rbenv on Ubuntu 18.04 for Ubuntu 18.04 and from Tsu2’s Ruby Guide for OpenSUSE.

This setup guide has been tested on OpenSUSE Leap versions 15.1 and 15.0.

ℹ️

These requirements should be the same for most versions of OpenSUSE. If you come across any bugs please report them as a github issue at: doc-susemanager Issues

Procedure: Installing rbenv
  1. Install rbenv build prerequisites:

    sudo zypper install automake gdbm-devel libyaml-devel sqlite3-devel \
    ncurses-devel readline-devel zlib-devel git gcc libopenssl-devel
  2. Once the prerequisites have finished installing open a terminal (You should be in your home directory). Clone the rbenv git repository:

    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
  3. Next, add ~/.rbenv/bin to your $PATH so that you can use the rbenv command line utility. Do this by altering your ~/.bashrc file so that it affects future login sessions:

    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
  4. Then add the command eval "$(rbenv init -)" to your ~/.bashrc file so rbenv loads automatically:

    echo 'eval "$(rbenv init -)"' >> ~/.bashrc
  5. Next, apply the changes you made to your ~/.bashrc file to your current shell session:

    source ~/.bashrc
  6. Verify that rbenv is set up properly by using the type command, which will display more information about the rbenv command:

    type rbenv

    You terminal window will display the following:

    rbenv is a function
    rbenv ()
    {
        local command;
        command="${1:-}";
        if [ "$#" -gt 0 ]; then
            shift;
        fi;
        case "$command" in
            rehash | shell)
                eval "$(rbenv "sh-$command" "$@")"
            ;;
            *)
                command rbenv "$command" "$@"
            ;;
        esac
    }
  7. Next, install the ruby-build, plugin. This plugin adds the rbenv install command, which simplifies the installation process for new versions of Ruby:

    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
  8. Test that your installation is successful by typing rbenv on the command line. You should see the following output:

    guides@linux-059r:~> rbenv
    rbenv 1.1.2-2-g4e92322
    Usage: rbenv <command> [<args>]
    
    Some useful rbenv commands are:
       commands    List all available rbenv commands
       local       Set or show the local application-specific Ruby version
       global      Set or show the global Ruby version
       shell       Set or show the shell-specific Ruby version
       install     Install a Ruby version using ruby-build
       uninstall   Uninstall a specific Ruby version
       rehash      Rehash rbenv shims (run this after installing executables)
       version     Show the current Ruby version and its origin
       versions    List installed Ruby versions
       which       Display the full path to an executable
       whence      List all Ruby versions that contain the given executable
    
    See `rbenv help <command>' for information on a specific command.
    For full documentation, see: https://github.com/rbenv/rbenv#readme

At this point, you have both rbenv and ruby-build successfully installed. Let’s install Ruby next.

With the ruby-build plugin now installed, you can install multiple and any versions of Ruby you may need through a simple command.

  1. First, let’s list all the available versions of Ruby:

    rbenv install -l
  2. The output of that command should be a long list of versions that you can choose to install. Scroll to the top or pipe the command through less to see a page at a time rbenv install -l | less.

  3. For our purposes we need to install Ruby 2.6.3 the latest stable version:

    rbenv install 2.6.3
  4. To set this specific version of ruby as your global version run the following command:

    rbenv global 2.6.3
  5. Verify that Ruby was properly installed by checking its version number:

    ruby -v

    If you installed version 2.6.3 of Ruby, your output to the above command should look something like this:

    guides@linux-059r:~> ruby -v
    ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

To install and use a different version of Ruby, run the rbenv commands with a different version number, as in rbenv install 2.5.0 and rbenv global 2.5.0.

You now have at least one version of Ruby installed and have set your default Ruby version. Next, we will set up asciidoctor and asciidoctor-pdf.

Continue to Install nvm

Clone this wiki locally