Before starting: Make sure you have the necessary folders and permissions — get more information.

Links: Homepage | Downloads
Dependencies: OpenSSL
Version: 2.4.2

Get the Code

Switch to /usr/local/src and download the source package.

cd /usr/local/src
curl --remote-name

Extract the archive and move into the folder.

tar -xzvf ruby-VERSION.tar.gz
cd ruby-VERSION

Compile and Install

Configure, compile and install into /usr/local/mac-dev-env/ruby-VERSION.

./configure \
  --prefix=/usr/local/mac-dev-env/ruby-VERSION \
make install

Create a symbolic link to /usr/local/ruby.

ln -s mac-dev-env/ruby-VERSION /usr/local/ruby


Execute the following lines to update your Bash startup script.

echo 'export PATH=/usr/local/ruby/bin:$PATH' >> ~/.bash_profile
echo 'export MANPATH=/usr/local/ruby/share/man:$MANPATH' >> ~/.bash_profile

Load the new shell configurations.

source ~/.bash_profile

Verify the Installation

Verify that you have successfully installed Ruby.

ruby --version