Complete Guide to Homebrew Installation and Configuration on macOS

Nov 02, 2025 · Programming · 17 views · 7.8

Keywords: Homebrew | macOS | Package Manager | Installation Guide | Path Configuration

Abstract: This article provides a comprehensive analysis of installing the Homebrew package manager on macOS systems, covering common error solutions, path configuration methods, and chip architecture adaptation. Through in-depth examination of installation script mechanisms and system environment setup, it helps users resolve typical issues like 'command not found' and ensures proper Homebrew functionality.

Fundamental Principles of Homebrew Installation

Homebrew, as a widely used package manager on macOS, involves multiple technical aspects during installation including system path configuration, script execution permissions, and dependency environment detection. When users encounter 'command not found' errors while using brew install commands, it typically indicates either improper Homebrew installation or incorrect system path configuration.

Detailed Standard Installation Process

According to Homebrew official documentation and best practices, the correct installation command is:

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

This command downloads the installation script from the GitHub repository using curl and executes it with the bash interpreter. The installation script automatically detects system architecture, installing to /opt/homebrew directory on Apple Silicon Macs and /usr/local/bin directory on Intel-based Macs.

Path Configuration and System Integration

After installation completes, the Homebrew binary path must be added to the system PATH environment variable. For users with zsh shell (default on macOS Catalina and later), add to ~/.zshrc file:

export PATH=/opt/homebrew/bin:$PATH

Then execute source ~/.zshrc to make the configuration take effect immediately. For bash shell users, the corresponding configuration should be added to the ~/.bashrc file.

Chip Architecture Adaptation Analysis

Different chip architectures require different path configurations:

# Apple Silicon (M1/M2 chips)
export PATH=/opt/homebrew/bin:$PATH

# Intel chips
export PATH=/usr/local/bin:$PATH

The installation script automatically identifies chip type and selects the correct installation path, but users need to manually configure PATH variables based on actual installation locations.

Installation Verification and Troubleshooting

After installation and configuration, verify using:

brew --version
brew help

If 'command not found' errors persist, check: whether the installation script executed successfully, whether PATH configuration is correct, and whether shell configuration has been reloaded. It's recommended to close all terminal windows and reopen for testing.

Historical Version Comparison

Before 2020, Homebrew used Ruby scripts for installation:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The current version uses bash script installation, providing better compatibility and error handling mechanisms.

Advanced Configuration Options

For users with special requirements, Homebrew supports various advanced configurations:

# Using Git mirrors for acceleration
export HOMEBREW_BREW_GIT_REMOTE="mirror address"
export HOMEBREW_CORE_GIT_REMOTE="mirror address"

# Non-interactive installation (suitable for automation scripts)
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

System Requirements and Compatibility

Homebrew requires macOS Sonoma (14) or later, supporting both Apple Silicon and 64-bit Intel chips. Command Line Tools for Xcode must be installed, obtainable via xcode-select --install command.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.