Amazon Cyber Monday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Where Does Brew Install? Homebrew Paths Explained

If you’ve ever run brew install and wondered where the files actually landed, you’re not alone. Homebrew’s default installation prefix is /usr/local on Intel Macs and /opt/homebrew on Apple Silicon, but the exact paths for binaries, libraries, and configuration files follow a consistent, logical structure. This guide walks you through every location Homebrew uses, so you can find, manage, and troubleshoot your installed packages with confidence.

Ingredients

  • 1 working Homebrew installation (check with brew --version)
  • 1 terminal window (Terminal.app or iTerm2)
  • 1 package installed via brew install (e.g., wget or tree)
  • Optional: brew list output for reference

Instructions

  1. Determine your Homebrew prefix. Run brew --prefix in your terminal. On Intel Macs, this typically returns /usr/local; on Apple Silicon (M1/M2/M3), it returns /opt/homebrew. This is the root of everything Homebrew does.
  2. Find installed binaries. Executables from formulae are symlinked into $(brew --prefix)/bin (e.g., /opt/homebrew/bin). When you run a command like wget, macOS searches your PATH and finds this symlink, which points to the actual binary inside the Cellar.
  3. Locate the real files in the Cellar. The actual package contents live in $(brew --prefix)/Cellar/<formula>/<version>. For example, /opt/homebrew/Cellar/wget/1.21.4 contains the bin/, lib/, and share/ directories for that specific version. Run brew --cellar <formula> to get the exact path for any package.
  4. Check the opt directory for stable symlinks. Homebrew creates $(brew --prefix)/opt/<formula> as a symlink to the current version in the Cellar. This is useful for scripts that need a consistent path regardless of version updates. For instance, /opt/homebrew/opt/wget always points to the latest installed wget.
  5. Find configuration files. Formula-specific configs usually live in $(brew --prefix)/etc (e.g., /opt/homebrew/etc). For example, if you install OpenSSL, its config might be at /opt/homebrew/etc/openssl. Some formulae use $(brew --prefix)/var for runtime data like databases (e.g., MySQL stores data in /opt/homebrew/var/mysql).
  6. Understand the Library directory. Homebrew itself (the framework) is in $(brew --prefix)/Library, which contains Taps (third-party repositories), Homebrew (core scripts), and Caches. You rarely need to touch this, but it’s good to know where it is.
  7. Check the cache for downloaded archives. Homebrew downloads source tarballs and bottles to ~/Library/Caches/Homebrew (or $(brew --prefix)/Caches on some setups). These are used for offline installs and can be safely deleted with brew cleanup to free space.
  8. Verify with a real example. Run brew install tree (if not already installed). Then run which tree to see the symlink path (e.g., /opt/homebrew/bin/tree). Run brew --cellar tree to see the actual versioned directory. Run ls -l $(which tree) to see where the symlink points.

Tips

  • Don’t manually delete files from the Cellar. Always use brew uninstall <formula> to remove packages. Manually deleting can break symlinks and leave orphaned files.
  • Use brew list to see all installed files. This command shows every file Homebrew manages for a formula, which is helpful for finding stray configs or binaries.
  • If a command isn’t found, check your PATH. Ensure $(brew --prefix)/bin is in your PATH (usually added by Homebrew’s install script). Run echo $PATH to verify.
  • For services (like databases), use brew services. This starts and stops services, and the logs are typically in $(brew --prefix)/var/log. Knowing this helps debug service issues.

Serving Suggestions

Once you know where Homebrew installs things, you can integrate these paths into your workflow. For example, add /opt/homebrew/bin to your editor’s PATH, or reference $(brew --prefix)/opt/<formula> in build scripts for consistent paths. You can also use brew --prefix in shell aliases to make your dotfiles portable across Macs.

Variations

  • Homebrew on Linux: The default prefix is /home/linuxbrew/.linuxbrew (or ~/.linuxbrew for user installs). The structure is identical: bin, Cellar, opt, etc.
  • Custom prefix: If you installed Homebrew in a custom location (e.g., ~/homebrew), all paths shift accordingly. Run brew --prefix to know exactly.
  • Using brew --prefix in scripts: Instead of hardcoding paths, use $(brew --prefix) in shell scripts to keep them portable across different Homebrew installations.

Storage and Reheating

Homebrew’s files are not meant to be moved or “reheated” like leftovers. If you need to free space, run brew cleanup to remove old versions and cached downloads. This typically frees several hundred MB. The cache can grow large over time, so consider running cleanup monthly. If you want to move your entire Homebrew installation, it’s safer to reinstall via the official script rather than copying directories, as symlinks and permissions can break.

Frequently Asked Questions

Q: Why does which brew show /usr/local/bin/brew on my Intel Mac?
A: That’s the symlink Homebrew creates in the bin directory. The actual Homebrew installation is in /usr/local/Homebrew, but the brew command is symlinked to /usr/local/bin so it’s in your PATH.

Q: Where are the configuration files for a formula like nginx?
A: Nginx’s config is in $(brew --prefix)/etc/nginx/. For most formulae, configs go into etc, but check the formula’s documentation with brew info nginx to see exact paths.

Q: Can I change the installation prefix to something else?
A: Yes, but it’s not recommended. You’d need to reinstall Homebrew with a custom prefix, and many formulae assume the standard paths. If you must, follow the official Homebrew documentation for custom prefixes, but be prepared for potential issues.

Q: Why do I see both /usr/local/bin and /opt/homebrew/bin in my PATH?
A: This can happen if you migrated from an Intel Mac to Apple Silicon, or if you have multiple Homebrew installs. It’s best to keep only the one that matches your architecture to avoid conflicts. Check with brew --prefix and remove the other from your PATH.

Q: How do I find where a specific file from a formula was installed?
A: Use brew list <formula> to see all files, or brew --prefix <formula> to get the opt path. For example, brew --prefix openssl returns /opt/homebrew/opt/openssl.

Q: Is it safe to delete files in ~/Library/Caches/Homebrew?
A: Yes, these are just downloaded archives. Deleting them frees space, but Homebrew will re-download if needed. Use brew cleanup to do this safely.

Where Does Brew Install? Homebrew Paths Explained
Scroll to top