How to Install and Use Homebrew on macOS

· Category: VS Code & Developer Tools

Short answer

Homebrew is the most popular package manager for macOS. It installs command-line tools and GUI apps from the terminal using simple commands.

Steps

  1. Open Terminal and paste the installation command from brew.sh.
  2. Wait for the script to install Xcode Command Line Tools and Homebrew.
  3. Run brew doctor to verify the installation.
  4. Install packages with brew install <package>, such as brew install git.
  5. Upgrade all packages with brew update && brew upgrade.

Tips

  • Use brew cask to install GUI applications like VS Code or Chrome.
  • Pin a package to prevent it from upgrading with brew pin <package>.
  • Regularly run brew cleanup to free disk space from old versions.

Common issues

  • Permission errors often mean you need to fix directory ownership with sudo chown.
  • The M1/M2 Mac requires some packages to run under Rosetta or ARM-specific taps.