Installing Ruby  

Introduction

In order to run Ruby code you need to install a Ruby interpreter.

Installing a Ruby interpreter for Windows is straightforward, but for Mac and Linux it is slightly more complicated. The default Ruby interpreters normally supplied on Mac and Linux are not adequate for running Watir and related Ruby technologies without making significant alterations to them.

There are different options for properly maintaining a Ruby interpreter, but we have chosen rbenv as the most suitable Ruby interpreter for Mac and chruby for Linux.

Note that RVM is an acceptable (if more complicated) way to maintain a Ruby interpreter if you prefer to use it, but if you choose to use rbenv or chruby, be sure to uninstall RVM completely.

Windows

Mac

Hold down the Command key and press the spacebar to open Spotlight search Type Terminal and hit enter

Install XCode command-line tools

Copy and paste this into the terminal and hit enter:

xcode-select --install

Install HomeBrew

Copy and paste this into the terminal and hit enter:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install rbenv

Copy and paste this into the terminal:

brew install readline rbenv ruby-install
rbenv init
touch ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile

Copy and paste this into the terminal (update version to latest release if desired):

rbenv install 3.0.0
rbenv local 3.0.0

Linux

Install git Copy and paste this into the terminal:

sudo apt-get install git

Install ruby-install Copy and paste this into the terminal:

wget -O ruby-install-0.8.1.tar.gz https://github.com/postmodern/ruby-install/archive/v0.8.1.tar.gz
tar -xzvf ruby-install-0.8.1.tar.gz
cd ruby-install-0.8.1/
sudo make install
ruby-install ruby 3.0.0

Install chruby Copy and paste this into the terminal:

cd ../
wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz
tar -xzvf chruby-0.3.9.tar.gz
cd chruby-0.3.9/
sudo make install
sudo ./scripts/setup.sh
xed ~/.bash_profile

Copy and paste this into the bash_profile file that opened in TextEdit:

source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh

Save file and Close TextEdit

Copy and paste this into the terminal and hit enter:

source ~/.bash_profile
chruby 3.0.0

Last Updated: November 19, 2019