Installing Homebrew and Fixing Ruby on your Mac
This post describes how to install homebrew, as as well as casks (software applications).
This post is an updated version from: Dec. 10, 2019.
Step 1: Open Your Terminal program
Search in launchpad or spotlight for "Terminal.app"
Step 2: Accept the license agreements
Copy and paste the below commands in your terminal. Be sure to read and accept the agreements.
xcode-select --install sudo xcodebuild -license
Step 3: Check if Ruby is installed
Make sure that you can run ruby from command line by typing:
Homebrew is basically a package manager for the Mac, and in this being used to fix the default Ruby version that comes with the Mac. It will also be used further into the tutorial to install other development items.
Copy Install Script
Go to the homebrew site (brew.sh) and check out the latest download code and run in in the terminal. It should look something like this:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once the install has completed, its best to run the below commands to make sure your installation is okay and has the latest files.
Updating Homebrew packages
To update packages, you will need to run an update, and upgrade like below:
brew update brew upgrade
Once in awhile you may want to also clean up unneeded files by this command:
Install some brew packages
You can install a package (called Formulae) either in bulk or one at a time.
One at a time:
brew install wget
Or many at once:
brew install wget node [email protected]
ffmpeg: is a great library for converting videos, and more. To install the with the default settings:
brew tap homebrew-ffmpeg/ffmpeg brew install homebrew-ffmpeg/ffmpeg/ffmpeg
Check out the homebrew github repo to see the options: ffmpeg Github repository
Installing the Mongo Database is similar to ffmpeg. Run the following steps:
brew tap mongodb/brew brew install mongodb-community
To run as background service:
brew services start mongodb/brew/mongodb-community
Run on demand (in terminal):
mongod --config /usr/local/etc/mongod.conf
Enable and Install Casks
Casks is basically software that you can install directly from homebrew, instead of going to a site and downloading a file. I prefer casks, as it will also run a sha check (if available), and will output errors to your screen (if issues).
brew tap homebrew/cask-versions
Unfortunately, I could not find a way to bulk install casks anymore, so you will need to run them one at a time (replacing "firefox" with the formulae name).
brew install --cask firefox
A list of great casks are below. To find more, the homebrew site has a huge database of ones available: Homebrew formulae
For some installations, if they fail, retry after you enable it in: System Preferences → Security & Privacy → General.
If you want to run multiple Java Versions, check out this guide: Installing Java on a Mac using Homebrew and jevn-12m8
Update Ruby and installed gems.
Run the command:
brew install ruby
Next, make sure you add Ruby to your shell configuration. Below is the shell for the default in Big Sur:
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc exec zsh
exec zsh: will restart your terminal so the path kicks in. If you do not ant to run this, simple type exit, then quit your terminal application and reopen it.
Next, update your ruby gems:
gem update --system gem update
Or if you want to have multiple versions, follow this great digital ocean guide: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos