Installing Ruby/Rails on macOS High Sierra

In this guide, I will walk you through installing Brew, Ruby, and Rails on macOS High Sierra (currently the latest release). It is fairly straightforward on how to install it and run it.

Installing Xcode

With the newest release, Apple has made a ton of changes to the CL Tools and it practically forces you to install xcode, so that's what we'll do.

xcode-select --install

Installing Oh My Zsh

If you don't have a bash terminal and want one, I'd recommend using Oh My Zsh, which I really like. It is simple to install.

sh -c "$(curl -fsSL"

Installing Brew

Let's install homebrew, which will allow us to install several packages for what we need.

ruby -e "$(curl -fsSL"
brew doctor
brew update

Installing Rbenv

We will then install ruby versioning which will allow us to have several different versions of ruby when needed.

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

echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc

Installing Ruby

Using rbenv, we will install the latest ruby version and set it as our global version.

rbenv install 2.4.1
rbenv rehash
rbenv global 2.4.1

Installing Rails

We will now pull in bundler which will allow us to install and run rails and additional gems. We then rehash rbenv environment to update it with our latest content. The last line of the code tells our gemrc to ignore any documentation that comes with any future gems we install. This free up space, since we will never really use it anyway.

gem install bundler
gem install rails
rbenv rehash
echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc

Installing Databases

Next we will install PostgreSQL, Redis, and MySQL.

brew install mysql postgresql redis

Installing Node

Finally, our last step will be to install node which will be used off and on by our servers.

brew install node

Installing Image Magick

I tend to use Imagick a lot for the manipulation of picture uploads whether in PHP or Ruby. This is also a great package to install.

brew install sqlite3 imagemagick

Raw Github

Here is a raw Github file shell script to install everything I use through brew. Simple copy and paste this into your terminal.

curl -L | sh