Homebrew on Apple Silicon (M1/M2) Installation and Setup
This guide covers the proper installation and configuration of Homebrew on Apple Silicon Macs (M1/M2 processors) to resolve the common error: "Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)".
Problem Overview
Apple Silicon Macs use ARM architecture, which requires a different Homebrew installation approach than Intel-based Macs. The error occurs because:
- Intel-based Homebrew installs to
/usr/local
- Apple Silicon Homebrew requires
/opt/homebrew
- Attempting to use the Intel installation path on ARM processors causes compatibility issues
Recommended Solution: Clean Installation
The most reliable approach is a clean installation of Homebrew for Apple Silicon.
Step 1: Uninstall Existing Homebrew (If Applicable)
If you have an existing Homebrew installation, remove it first:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
For a complete removal, use the non-interactive option:
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Step 2: Install Homebrew for Apple Silicon
Run the standard installation script:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This will automatically install to the correct location (/opt/homebrew
) for Apple Silicon.
Step 3: Configure Your Shell
After installation, Homebrew will provide instructions to add it to your PATH. Typically, you need to add this to your shell configuration file (~/.zshrc
for macOS Catalina and later):
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
Then apply the changes:
eval "$(/opt/homebrew/bin/brew shellenv)"
Step 4: Verify Installation
Confirm Homebrew is correctly installed:
brew doctor
You should see: "Your system is ready to brew."
Check that brew points to the correct location:
which brew
# Should return: /opt/homebrew/bin/brew
Alternative: Manual Installation
If the standard installation doesn't work, you can manually install to the correct location:
# Create the directory
sudo mkdir -p /opt/homebrew
# Set appropriate permissions
sudo chown -R $(whoami):staff /opt/homebrew
sudo chmod -R go-w /opt/homebrew
# Install Homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /opt/homebrew
# Add to PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/opt/homebrew/bin/brew shellenv)"
Using Both ARM and Intel Versions
INFO
Some packages may not yet have ARM versions available. In these cases, you might need to maintain both ARM and Intel Homebrew installations.
Installing Intel Homebrew (Via Rosetta 2)
First, install Rosetta 2 if you haven't already:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
Then install Intel Homebrew:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Creating Aliases for Both Versions
Add these aliases to your ~/.zshrc
file:
alias abrew="/opt/homebrew/bin/brew" # ARM Brew
alias ibrew="arch -x86_64 /usr/local/bin/brew" # Intel Brew
Usage examples:
abrew install package_name # Install for ARM
ibrew install package_name # Install for Intel
Troubleshooting Common Issues
Terminal Running in Rosetta Mode
Some terminal applications might default to Rosetta (Intel) mode. Check this by running:
uname -m
- Apple Silicon should return:
arm64
- Intel mode will return:
x86_64
WARNING
If your terminal is running in Intel mode, it will try to use the Intel Homebrew installation. Either switch to ARM mode or use the Intel Homebrew commands.
Migration from Intel Mac
If you migrated from an Intel Mac, you might need to completely remove the old installation:
sudo rm -rf /usr/local/Homebrew
sudo rm -rf /usr/local/bin/brew
Then follow the clean installation steps above.
Permission Issues
If you encounter permission errors, ensure proper ownership:
sudo chown -R $(whoami):staff /opt/homebrew
Best Practices
- Use ARM Homebrew by default - Most packages now support Apple Silicon
- Only use Intel Homebrew when necessary - For packages without ARM support
- Keep both installations updated - Regularly run
brew update
on both installations - Use descriptive aliases - Make it clear which architecture you're installing for
TIP
Run brew doctor
regularly to check for potential issues with your Homebrew installation.
Conclusion
The "Cannot install in Homebrew on ARM processor" error is resolved by ensuring Homebrew is installed in the correct location (/opt/homebrew
) for Apple Silicon Macs. For most users, a clean installation following the standard Homebrew install process will work correctly. For edge cases where Intel packages are needed, maintaining both ARM and Intel Homebrew installations with clear aliases provides the most flexible solution.