How to Install Homebrew in macOS
Homebrew is one of the most popular package managers for macOS. It allows you to install developer tools, libraries, and utilities directly from the terminal with a single command.
Although Homebrew installation looks simple, many users struggle with it because of path issues, shell differences (bash vs zsh), or Apple Silicon vs Intel Macs. I’ve personally faced different behaviors across macOS versions, but following the steps below will work reliably.
What Is Homebrew?
Homebrew is a free and open-source package manager that simplifies software installation on macOS. Instead of manually downloading and configuring tools, Homebrew manages everything for you.
How to Install Homebrew
Homebrew can be installed in two ways:
- Using the command line (recommended)
- Using a .pkg installer
Download the .pkg file from here: Homebrew PKG Installer
Install Homebrew Using Command Line
Open the Terminal app on your Mac and paste the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Press Enter and allow the installation to complete. This may take a few minutes depending on your internet speed.
Once installation finishes, you should ideally be able to use the brew command immediately. However, this is where most users face issues.
Verify Homebrew Installation
Run the following command to check whether Homebrew is installed:
brew --version
If Homebrew is correctly installed and configured, you’ll see output like:
Homebrew 4.x.x
If not, you’ll encounter the following error:
brew: command not found
Fix: brew Command Not Found (PATH Issue)
On newer macOS versions (especially Apple Silicon Macs), Homebrew is installed under:
/opt/homebrew/bin
macOS does not automatically add this location to your system PATH. You need to add it manually.
First, check your current PATH:
echo $PATH
Now add Homebrew to your PATH:
export PATH=$PATH:/opt/homebrew/bin
Verify that the Homebrew path is added:
echo $PATH
Close all Terminal windows and open a new one. Then run:
brew help
If Homebrew is set correctly, you’ll see the list of available commands.
Make PATH Permanent (Recommended)
To avoid setting the PATH every time, add it permanently to your shell configuration.
For zsh (default shell on modern macOS):
echo 'export PATH=$PATH:/opt/homebrew/bin' >> ~/.zshrc
source ~/.zshrc
For bash:
echo 'export PATH=$PATH:/opt/homebrew/bin' >> ~/.bash_profile
source ~/.bash_profile
Check Your Shell (bash or zsh)
Sometimes Homebrew appears installed but doesn’t work due to shell mismatch. Check your shell using:
echo $SHELL
If needed, switch to bash and retry the installation:
bash
Then repeat the installation steps.
Confirm Installation
Finally, verify everything is working:
brew doctor
If no errors appear, Homebrew is ready to use 🎉
You can now install packages like:
brew install node
brew install git
Enjoy hassle-free package management on macOS!
Prakash Pradhan
Sr. Software Engineer
Senior Software Engineer with 10+ years of experience in designing and scaling distributed systems and full-stack applications. Experts in optimizing system performance, and delivering high-impact technical solutions across the entire software development lifecycle.
Comments
No comments yet.