Yes, you can install Homebrew on a Mac by running a single command in the Terminal, and this guide walks you through the exact steps, prerequisites, and common troubleshooting. Homebrew is a free, open-source package manager that lets you install, update, and manage Unix tools and apps that Apple doesn’t include by default. By the end, you’ll have Homebrew running and know how to use it for everyday tasks like installing Python, Git, or even GUI applications.
What Is Homebrew and Why Use It?
Homebrew is a package manager for macOS (and Linux) that simplifies installing software from source or precompiled binaries. Instead of manually downloading a tarball, configuring paths, and chasing dependencies, you type one command like brew install wget and Homebrew handles the rest. It installs packages into its own directory (/opt/homebrew on Apple Silicon, /usr/local on Intel) and symlinks them into system paths, so you can run them from anywhere in the Terminal.
Why bother? Because many developer tools, command-line utilities, and even desktop apps are distributed through Homebrew. It also keeps everything up to date with brew update and brew upgrade, and it cleans up old versions easily. If you’re a developer, data scientist, or just someone who likes using open-source tools, Homebrew is the de facto standard on macOS.
Prerequisites: What You Need Before Installing
Before you run the install command, make sure your Mac meets these requirements:
- macOS version: Homebrew currently supports macOS Monterey (12) or newer. Older versions might work but are not officially supported.
- Command Line Tools: Homebrew requires Apple’s Command Line Tools (CLT), which include Git, clang, and other compilers. The installer will prompt you to install them if they’re missing, but you can also install them manually with
xcode-select --install. - Terminal access: You’ll use the built-in Terminal app (or any other terminal emulator). You need an administrator account because Homebrew creates directories in system locations.
- Internet connection: The installer downloads files from GitHub and other servers, so a stable connection is required.
- Processor architecture: Homebrew installs to different paths depending on whether your Mac uses an Intel or Apple Silicon (M1/M2/M3) chip. This matters for environment variables and some packages that have architecture-specific versions.
Step-by-Step Installation Instructions
Here’s the exact process to install Homebrew on a modern Mac. Open Terminal (found in Applications > Utilities) and follow these steps:
- Install Command Line Tools (if not already present): Run
xcode-select --install. A pop-up will appear; click “Install” and agree to the license. This can take a few minutes. - Run the official installer: Paste this command and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Enter your password: The script will ask for your macOS user password. It won’t show characters as you type—that’s normal. Press Enter after typing.
- Confirm the installation: The script will show what it’s about to do and ask you to press Return to continue. Do so.
- Wait for it to finish: The installer downloads and sets up Homebrew. It may take several minutes depending on your connection.
- Follow the “Next steps” message: After installation, the script prints instructions to add Homebrew to your PATH. On Apple Silicon, you’ll see something like:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
On Intel, it’s usually/usr/local/bin/brew. Run the commands it shows. - Verify the installation: Close and reopen Terminal, then run
brew --version. You should see the Homebrew version number (e.g.,Homebrew 4.3.0).
Common Installation Problems and Fixes
Even though the installer is automated, you might hit a few issues. Here are the most common ones and how to solve them:
- “Command Line Tools not found” error: If
xcode-select --installfails or you get a “can’t install” message, go to Apple’s developer site (developer.apple.com/download/all/) and download the Command Line Tools for your macOS version manually. Then run the installer again. - “Failed to connect to raw.githubusercontent.com” or curl errors: This is usually a network or firewall issue. Try again later, or use a different network. Some corporate networks block raw GitHub content; using a VPN might help.
- “Permission denied” or “Operation not permitted” during installation: Make sure you’re running the command as an admin user. If you’re using a company-managed Mac, you might need IT approval to install software in system directories.
- Homebrew installs but
brewcommand not found: This means the PATH wasn’t updated. Re-run the “Next steps” commands from the installer output. For Apple Silicon, the path is/opt/homebrew/bin; for Intel, it’s/usr/local/bin. Add it to your shell profile manually if needed. - “Error: Not a valid ref: refs/remotes/origin/master” when updating: This is a Git issue. Run
cd /opt/homebrew && git fetch --prune && git reset --hard origin/master(or/usr/localon Intel) to fix it.
Using Homebrew: Basic Commands You’ll Actually Use
Once installed, these are the commands you’ll use most often:
brew install <package>– Install a package, e.g.,brew install git.brew uninstall <package>– Remove a package.brew list– Show all installed packages.brew search <term>– Search for a package by name.brew update– Update Homebrew itself and its package index.brew upgrade– Upgrade all installed packages to the latest versions.brew cleanup– Remove old versions of packages.brew doctor– Check your Homebrew installation for issues and get advice.
You can also install GUI applications with brew install --cask <app>, like brew install --cask google-chrome. This is handy for automating app installation and updates.
Uninstalling Homebrew Safely
If you ever want to remove Homebrew completely, there’s an official uninstall script. Run this in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
The script will ask for confirmation and remove Homebrew, its downloaded files, and the symlinks it created. It will not remove packages you installed with it unless you choose the “purge” option. After uninstalling, you may want to manually clean up the /opt/homebrew or /usr/local/Homebrew directory if anything remains. Also, remove the PATH line you added to ~/.zprofile (or ~/.bash_profile).
Alternatives to Homebrew
Homebrew isn’t the only package manager for macOS. Depending on your needs, you might consider these:
- MacPorts: An older package manager that installs software into
/opt/local. It’s more traditional but requires more manual configuration and often compiles from source, which is slower. - Fink: Another older option that’s less popular today. It uses Debian-style packages.
- Direct downloads: For simple apps, you can just download the .dmg or .pkg from the developer’s website. No package manager needed.
- App Store: For Mac apps, the App Store is the most user-friendly, but it lacks command-line tools and many open-source packages.
For most developers and power users, Homebrew is the best balance of ease, speed, and package availability. But if you prefer a more “set and forget” approach, MacPorts might suit you, though it’s less common.
Frequently Asked Questions
Is Homebrew safe to install on my Mac?
Yes, Homebrew is widely used and open-source. The install script is publicly available on GitHub, and the project is maintained by a large community. However, you should always review scripts before running them with sudo, and be aware that installing packages can introduce security risks if you install untrusted software. Stick to well-known packages and run brew doctor regularly.
Do I need to install Xcode to use Homebrew?
No, you only need the Command Line Tools, which are a subset of Xcode. You can install them separately with xcode-select --install without downloading the full Xcode app (which is several gigabytes).
Why does Homebrew install to /opt/homebrew on Apple Silicon?
Apple Silicon Macs use a different architecture (arm64) than Intel (x86_64). Homebrew uses /opt/homebrew for arm64 to avoid conflicts with Intel-based software installed in /usr/local. This separation prevents architecture mismatches.
Can I install Homebrew without admin rights?
No, the default installation requires admin access because it creates directories in system locations. However, you can install Homebrew in your home directory (e.g., ~/homebrew) by cloning the repository and adding it to your PATH, but this is not officially supported and can cause issues with some packages.
How do I update Homebrew and all my packages?
Run brew update to update Homebrew itself, then brew upgrade to upgrade all installed packages. You can also upgrade a single package with brew upgrade <package>. It’s a good idea to do this regularly to get security fixes.
What’s the difference between brew install and brew install --cask?
brew install is for command-line tools and libraries (like Python, Git, or wget). brew install --cask is for installing GUI applications (like Google Chrome, Visual Studio Code, or Slack). Casks are essentially automated installers for .dmg or .pkg files.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Change Window Border Width in Windows
- Enable iTunes Notification Center Widget on Mac
- Windows 10 Activation Error 0xc004c003: Fixes
- Modify Web Captures with JavaScript: A How-To
- How to Live Stream Using the Twitch Mobile App
- How to Change GPS Location on Android