Fixing "Warning: /opt/homebrew/bin is not in your PATH" on macOS M1
Problem Overview
When installing Homebrew on macOS Big Sur with an M1 chip, many users encounter the warning:
Warning: /opt/homebrew/bin is not in your PATH.
This warning indicates that while Homebrew has been successfully installed to /opt/homebrew/
, your system doesn't know where to find the Homebrew executables. The /opt/homebrew/
location is specifically used for ARM-based installations on Apple Silicon (M1) Macs.
Why This Happens
Homebrew changed its installation path for Apple Silicon Macs:
- Intel Macs:
/usr/local/bin
- Apple Silicon (M1/M2) Macs:
/opt/homebrew/bin
This separation allows both Intel and ARM versions of Homebrew to coexist on the same machine. The warning appears because your shell's PATH environment variable doesn't include the new location.
Solution: Add Homebrew to Your PATH
The most straightforward solution is to add the Homebrew path to your shell configuration file.
Method 1: Basic PATH Modification
Edit your shell configuration file:
- For Zsh (macOS Catalina and later):
~/.zshrc
- For Bash:
~/.bashrc
or~/.bash_profile
- For Zsh (macOS Catalina and later):
Add the following line at the end of the file:
bashexport PATH="/opt/homebrew/bin:$PATH"
Reload your shell configuration:
bashsource ~/.zshrc # or source ~/.bashrc
Method 2: Architecture-Aware Solution (Recommended)
If you use your configuration across multiple machines with different architectures, use this conditional approach:
# Add to your ~/.zshrc or ~/.bashrc
if [[ "$(uname -m)" == "arm64" ]]; then
export PATH="/opt/homebrew/bin:${PATH}"
fi
This only adds the path when running on Apple Silicon hardware, making your configuration portable.
Method 3: Using Homebrew's Recommended Commands
After installation, Homebrew often provides specific commands to complete setup. Check for any "Next steps" messages and run the provided commands, which typically include:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/opt/homebrew/bin/brew shellenv)"
Verifying the Fix
After making changes, verify that Homebrew is accessible:
brew --version
You should see Homebrew's version information without any "command not found" errors.
Additional Considerations
INFO
Homebrew has officially supported Apple Silicon since version 3.0.0. If you have an older version, run brew update
to get the latest updates with full M1 support.
WARNING
If you don't have a shell configuration file, create one using:
touch ~/.zshrc # or touch ~/.bashrc
For those who previously installed Homebrew under Rosetta 2, note that native Apple Silicon support is now recommended and generally works well for most packages.
Troubleshooting
If you still encounter issues:
Ensure Xcode Command Line Tools are installed:
bashxcode-select --install
Verify your architecture:
bashuname -m
Should return
arm64
for M1/M2 Macs.Check your current PATH:
bashecho $PATH
Ensure
/opt/homebrew/bin
appears at or near the beginning.
Conclusion
The PATH warning is a common but easily resolved issue when installing Homebrew on Apple Silicon Macs. By adding the appropriate path to your shell configuration, you'll ensure Homebrew commands work correctly while maintaining compatibility with both Intel and ARM architectures.
The solutions provided above will resolve the warning and ensure your Homebrew installation functions properly on your M1 Mac.