How to install homebrew on M1 mac
Categories:
Installing Homebrew on Apple Silicon (M1/M2/M3) Macs

A comprehensive guide to successfully installing and configuring Homebrew, the macOS package manager, on your Apple Silicon Mac.
Homebrew is an essential package manager for macOS, simplifying the installation of command-line tools, applications, and utilities. While Homebrew has traditionally run seamlessly on Intel-based Macs, Apple Silicon (M1, M2, M3) introduces a new architecture that requires specific considerations for optimal performance and compatibility. This guide will walk you through the correct steps to install Homebrew on your M1/M2/M3 Mac, ensuring you leverage its full potential.
Understanding Apple Silicon and Homebrew
Apple Silicon Macs use the ARM64 architecture, which is different from the x86-64 architecture of Intel Macs. Homebrew can be installed in two primary ways on an Apple Silicon Mac:
- Native ARM64 Installation: This is the recommended approach, installing Homebrew directly into
/opt/homebrew
. Tools installed this way will run natively on your Apple Silicon chip, offering the best performance. - Rosetta 2 (x86-64) Installation: This involves installing Homebrew into
/usr/local
and running it under Rosetta 2 emulation. While this allows you to use older, Intel-only formulae, it comes with a performance overhead and is generally not recommended unless absolutely necessary for specific, unsupported tools.
Prerequisites: Xcode Command Line Tools
Before installing Homebrew, you need to ensure that the Xcode Command Line Tools are installed. These tools provide essential compilers and utilities that Homebrew relies on. If you don't have them, the Homebrew installer will prompt you to install them, but it's good practice to do it beforehand.
1. Open Terminal
Launch the Terminal application from your Applications/Utilities folder, or by searching for it with Spotlight (Cmd + Space).
2. Install Xcode Command Line Tools
Execute the following command in your Terminal to install the Xcode Command Line Tools. If they are already installed, the system will inform you.
xcode-select --install
Command to install Xcode Command Line Tools
A dialog box will appear asking you to confirm the installation. Click 'Install' and agree to the terms and conditions. The download and installation process may take some time depending on your internet connection.
Installing Homebrew Natively (Recommended)
This is the standard and recommended method for installing Homebrew on Apple Silicon Macs. It installs Homebrew to /opt/homebrew
, ensuring all installed packages run natively on your M1/M2/M3 chip.
1. Execute the Homebrew Installation Script
Copy and paste the following command into your Terminal and press Enter. This command downloads and runs the official Homebrew installation script.
2. Follow On-Screen Prompts
The script will explain what it's going to do and prompt you to press RETURN
to continue. It may also ask for your macOS user password to grant necessary permissions for installation.
3. Add Homebrew to your PATH
After the installation completes, the script will output instructions to add Homebrew to your system's PATH. This is crucial for your shell to find Homebrew commands. You'll typically see something like the following, which you should copy and paste into your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Official Homebrew installation command
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Commands to add Homebrew to PATH for zsh (default shell on macOS)
bash
), the script will provide the appropriate commands for your shell configuration file (e.g., ~/.bash_profile
or ~/.bashrc
). Always follow the instructions provided by the installer.Verifying the Installation
Once Homebrew is installed and added to your PATH, you can verify that it's working correctly and that it's the native ARM64 version.
1. Check Homebrew Version
Run the following command to check the installed Homebrew version.
2. Check Homebrew Doctor
The brew doctor
command checks for potential issues with your Homebrew installation. It's a good practice to run this after installation.
brew --version
Verify Homebrew version
brew doctor
Check for Homebrew issues
You should see output indicating that Homebrew is installed and ready to use. The brew --version
output should show Homebrew 4.x.x
and Homebrew/homebrew-core (git revision ...; last commit ...)
.
flowchart TD A[Start] --> B{Check Xcode Command Line Tools?} B -- No --> C[Install Xcode Command Line Tools] B -- Yes --> D[Run Homebrew Install Script] C --> D D --> E{Add Homebrew to PATH?} E -- No --> F[Add 'eval "$(/opt/homebrew/bin/brew shellenv)"' to ~/.zprofile] E -- Yes --> G[Verify Installation] F --> G G --> H[Run 'brew --version'] H --> I[Run 'brew doctor'] I --> J[End]
Homebrew Installation Process on Apple Silicon
Installing Packages with Homebrew
Now that Homebrew is installed, you can start installing packages. The syntax is straightforward.
brew install <package-name>
# Example: Install wget
brew install wget
# Example: Install a Cask application (GUI app)
brew install --cask google-chrome
Examples of installing packages and Cask applications