Ruby

From Leo's Notes
Last edited on 14 June 2020, at 23:25.

The easiest way to get Ruby running is to use RVM.

Ruby via RVM

Installation

Install RVM. Their installer script requires package signatures to match so importing their key is required.

# curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
# curl -L get.rvm.io | bash -s stable

## or if you want ruby:
# curl -L get.rvm.io | bash -s stable --ruby

Depending if the installer was executed as a super user, RVM will be installed to:

User RVM Location Profile Script
root /usr/local/rvm /etc/profile.d/rvm.sh
user ~/.rvm ~/.rvm/scripts/rvm (don't invoke, source the file)

Source the profile script in order to include RVM into the path. Otherwise, execute the rvm script manually.

Install the desired version of ruby. If you are not running this as root, the script will attempt to install them via sudo. The Ruby dependencies I needed were installed with:

# yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make  bzip2 autoconf automake libtool bison iconv-devel sqlite-devel

After the dependencies are installed, install ruby using rvm. You do not need to be root for this step, but all the source and compiled binaries are placed in your home directory.

# rvm install 2.2.3

Usage

As a normal user, source the profile script and use gem/ruby as you normally would.

Custom ruby gems will be installed in ~/ruby/gems. You may need to define the gems path manually by running GEM_PATH=$GEM_PATH:$HOME/ruby/gems

Binaries such as ruby and gem should be referenced from the rvm directory. To get ruby on rails working, run

gem install rails