Install Homebrew on M1 Mac
This guide covers the proper installation of Homebrew on Apple Silicon (M1/M2) Macs, addressing common PATH configuration issues that differ from Intel-based Macs.
The Core Problem
On Apple Silicon Macs, Homebrew installs to /opt/homebrew/bin
instead of the traditional /usr/local/bin
used on Intel Macs. If your shell doesn't include this path, Homebrew commands won't be recognized even after successful installation.
Installation Steps
Step 1: Install Homebrew
Open Terminal and run the official installation command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Follow the on-screen prompts. The installation may take several minutes.
Step 2: Configure Your PATH
After installation, Homebrew will display instructions similar to:
==> Next steps:
Run these two commands in your terminal to add Homebrew to your PATH:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
# Add to ~/.zprofile (runs at login)
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
# Apply changes immediately
eval "$(/opt/homebrew/bin/brew shellenv)"
# Add to ~/.zshrc (runs for every shell)
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc
# Apply changes immediately
source ~/.zshrc
TIP
The recommended method using brew shellenv
is preferred as it sets all necessary environment variables, not just the PATH.
Step 3: Verify Installation
Test that Homebrew is working correctly:
brew --version
brew help
Troubleshooting Common Issues
Command Line Tools Issues
If you encounter architecture errors mentioning x86_64
vs arm64e
, you may need to reinstall Command Line Tools:
# Remove existing tools
sudo rm -rf /Library/Developer/CommandLineTools
# Reinstall properly
xcode-select --install
File Doesn't Exist Errors
If you get errors about .zprofile
or .zshrc
not existing:
# Create the file if it doesn't exist
touch ~/.zprofile
Understanding the Difference
PATH Configuration Files
- ~/.zprofile: Executed at login (recommended for Homebrew)
- ~/.zshrc: Executed for each new shell session
Apple Silicon Macs use the /opt/homebrew
prefix instead of /usr/local
, requiring this path adjustment.
Verifying Successful Installation
After completing these steps, you should be able to:
- Run
brew install [package]
without errors - See Homebrew version information with
brew --version
- Access brew help with
brew help
The installation is complete when Homebrew commands execute without "command not found" errors.