Skip to content

Homebrew/install

Ever wished installing software on your Mac (or Linux box) was as easy as apt-get on Debian? That's exactly what Homebrew delivers — the "missing package manager for macOS" that's become the go-to way for developers to install tools, libraries, and apps. This script bootstraps the entire Homebrew ecosystem with a single curl command, detecting your OS and architecture, setting up the right directories, and even installing Xcode Command Line Tools if needed.

Script info

URL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
Invocation /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Total lines 1167
Comments 65 lines
Blank 90 lines
Boilerplate 150 lines (output formatting, colors, usage text)
Installation 862 lines (actual work)

What does it change?

This is a seriously thorough installer — it's been battle-tested by millions of developers and shows it. Let's break down what happens when you let it loose.

Files and folders

The big one: Homebrew creates its own little kingdom on your system.

On Apple Silicon Macs (M1/M2/M3):

  • Creates /opt/homebrew as the main prefix
  • Sets up a whole directory tree underneath: bin, etc, include, lib, sbin, share, opt, var, Cellar, Caskroom, Frameworks
  • Creates /etc/paths.d/homebrew so the brew command is automatically in your PATH

On Intel Macs:

  • Uses /usr/local as the prefix (classic location)
  • Creates /usr/local/Homebrew for the actual Homebrew code
  • Similar subdirectory structure as above

On Linux:

  • Creates /home/linuxbrew/.linuxbrew (yes, even if your username isn't "linuxbrew")
  • Same subdirectory structure

Cache directories:

  • macOS: ~/Library/Caches/Homebrew
  • Linux: ~/.cache/Homebrew

Downloads

The script clones the Homebrew repository from GitHub:

  • https://github.com/Homebrew/brew — the main Homebrew codebase
  • Optionally https://github.com/Homebrew/homebrew-core if you set HOMEBREW_NO_INSTALL_FROM_API

After the initial clone, it runs brew update to fetch the latest package definitions.

Packages installed (macOS only)

Here's a heads-up for macOS users: if you don't have Xcode Command Line Tools installed, this script will trigger their installation. That's a ~1GB download from Apple that includes git, compilers, and other developer essentials. The script tries to do this silently in the background, but may pop up a GUI dialog asking you to confirm.

Environment changes

The script itself doesn't modify your shell config, but it will politely tell you to add this line to your .zshrc, .bash_profile, or equivalent:

eval "$(brew shellenv)"

This sets up PATH, MANPATH, INFOPATH, and a few other environment variables so you can use brew and everything you install with it.

On ARM Macs, it also creates /etc/paths.d/homebrew which adds /opt/homebrew/bin to your system PATH automatically — no shell config editing required for basic functionality.

Permissions

The script needs admin access on macOS (it'll prompt for your password). Here's what it does with those elevated privileges:

  • Creates and sets ownership on the Homebrew prefix directory
  • Adjusts permissions so your user account owns everything (not root)
  • On macOS, the directories are owned by your user but grouped under admin
  • On Linux, it uses your primary group

One nice detail: the script specifically checks that you're not running as root (except in containers). It wants to install things owned by your regular user account, which is the secure way to do it.

Changed your mind?

Homebrew is actually pretty easy to uninstall cleanly. The Homebrew team provides an official uninstall script:

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

If you prefer the manual route:

  1. Remove the Homebrew directory:
  2. ARM Mac: sudo rm -rf /opt/homebrew
  3. Intel Mac: sudo rm -rf /usr/local/Homebrew (and carefully remove Homebrew-owned files from /usr/local)
  4. Linux: sudo rm -rf /home/linuxbrew

  5. Remove the paths.d entry (ARM Mac only):

    sudo rm /etc/paths.d/homebrew
    

  6. Remove the cache:

  7. macOS: rm -rf ~/Library/Caches/Homebrew
  8. Linux: rm -rf ~/.cache/Homebrew

  9. Clean up your shell config — remove the eval "$(brew shellenv)" line from your .zshrc/.bash_profile/etc.

  10. Xcode Command Line Tools can stay — they're useful for other things. But if you really want them gone: sudo rm -rf /Library/Developer/CommandLineTools

Full source

The full script source is saved as scripts/raw_githubusercontent_com_Homebrew_install_HEAD_install_sh.txt.