Installing Brew on MacOS

This article helps you get started with Brew, including installation.

How to Install Homebrew on MacOS: A Step-by-Step Guide

Homebrew, often referred to as “Brew,” is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system and Linux. The beauty of Homebrew lies in its ease of use, making it a favorite among developers and power users for installing, updating, and managing software packages. In this guide, we’ll walk you through the steps of installing Homebrew on MacOS, ensuring you have a smooth and successful setup.

Step 1: Check for Pre-requisites

Before installing Homebrew, ensure your MacOS meets the following requirements:

  • macOS Version: Homebrew supports the latest and several previous versions of macOS. Check the official Homebrew documentation for the specific versions currently supported.

  • Command Line Tools for Xcode: Homebrew relies on the Command Line Tools package for Xcode, which includes compilers and other necessary tools for command-line development.

To install the Command Line Tools for Xcode, open the Terminal app (found in /Applications/Utilities/) and enter the following command:

Shell Code

xcode-select --install

You’ll receive a prompt to start the installation process. Follow the on-screen instructions to complete the installation.

Step 2: Install Homebrew

With the prerequisites out of the way, you’re now ready to install Homebrew. To do so, paste the following command into your Terminal and hit Enter:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This command downloads and runs the Homebrew installation script from the official Homebrew GitHub repository. During the installation process, you may be prompted to enter your administrator password. This is necessary to allow Homebrew to perform operations requiring administrative privileges.

Step 3: Set Up Homebrew

After installation, you need to add Homebrew to your system’s PATH to use it directly from the Terminal. The installer will likely provide instructions on how to do this, but typically, you’ll need to add the following line to your .bash_profile or .zshrc file (depending on whether you’re using Bash or Zsh as your shell):

For Bash users:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

For Zsh users:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc

After adding this line, restart your Terminal or source your profile file with source ~/.bash_profile or source ~/.zshrc to apply the changes.

Step 4: Verify the Installation

To ensure Homebrew has been installed correctly, you can run the following command:

brew doctor

This command checks your system for potential issues with your Homebrew installation. If everything is set up correctly, you should see a message stating, “Your system is ready to brew.”

Step 5: Using Homebrew

With Homebrew installed, you can now easily install, uninstall, and manage software packages. For example, to install the latest version of Python, simply run:

brew install python

To update all your installed packages to their latest versions:

brew update

And to upgrade a specific package:

brew upgrade <formula>

Homebrew also supports its own versions of packages that may differ from those that come pre-installed on MacOS, providing you with more control over the software on your system.

Conclusion

Congratulations! You’ve successfully installed Homebrew on your MacOS system. This powerful tool opens up a world of possibilities for managing software packages efficiently. Whether you’re a developer, a power user, or just someone looking to streamline their software installations, Homebrew is an invaluable resource. Happy brewing!