Introduction
Homebrew is a popular package manager for macOS that simplifies software installation by handling dependencies and configurations automatically. This guide will walk you through installing Homebrew on different versions of macOS, including those with Apple Silicon (M1) chips.
Prerequisites
Before proceeding, ensure your system meets the following requirements:
-
Xcode Command Line Tools: These are necessary for compiling code from source.
To check if Xcode is installed:
/usr/bin/xcodebuild -version
If not installed, follow these steps to set it up:
- Open the Terminal and run:
xcode-select --install
- Once prompted, install Xcode Command Line Tools.
- To ensure Homebrew can find them, open Xcode > Preferences > Locations tab, then select your Xcode version from the "Command Line Tools" dropdown.
- Open the Terminal and run:
Installation Process
Standard macOS (Intel-based)
-
Install Homebrew:
Open Terminal and run the following command to download and install Homebrew:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Verify Installation:
After installation, verify it by running:brew doctor
This command checks for potential issues and confirms that Homebrew is set up correctly.
-
Update Homebrew:
Ensure you have the latest version of Homebrew packages:brew update
macOS with Apple Silicon (M1)
-
Install Homebrew:
Similar to Intel-based systems, but there are additional steps to set up your environment for M1 chips.Run the installation command in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Configure Shell Path:
After installation, append the Homebrew binary path to your shell configuration file to ensurebrew
is available in every new terminal session.For macOS with Apple Silicon, add this line to your
.zshrc
(default shell as of Catalina):echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc
-
Apply the Path Configuration:
To activate the changes immediately, run:source ~/.zshrc
-
Verify Installation:
Test the installation with:brew doctor
This ensures there are no configuration issues.
-
Update Homebrew:
Keep your package list updated:brew update
Additional Tips
- Always keep Homebrew and its packages updated to avoid compatibility issues.
- If you encounter errors,
brew doctor
is a helpful command for diagnosing common problems.
By following these steps, you should have a functional Homebrew installation ready on your macOS system. With Homebrew, managing software dependencies becomes straightforward, enhancing productivity and system management.