Skip to content

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

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:

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

For a complete removal, use the non-interactive option:

bash
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:

bash
/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):

bash
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc

Then apply the changes:

bash
eval "$(/opt/homebrew/bin/brew shellenv)"

Step 4: Verify Installation

Confirm Homebrew is correctly installed:

bash
brew doctor

You should see: "Your system is ready to brew."

Check that brew points to the correct location:

bash
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:

bash
# 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:

bash
/usr/sbin/softwareupdate --install-rosetta --agree-to-license

Then install Intel Homebrew:

bash
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:

bash
alias abrew="/opt/homebrew/bin/brew"  # ARM Brew
alias ibrew="arch -x86_64 /usr/local/bin/brew"  # Intel Brew

Usage examples:

bash
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:

bash
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:

bash
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:

bash
sudo chown -R $(whoami):staff /opt/homebrew

Best Practices

  1. Use ARM Homebrew by default - Most packages now support Apple Silicon
  2. Only use Intel Homebrew when necessary - For packages without ARM support
  3. Keep both installations updated - Regularly run brew update on both installations
  4. 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.