Published on

Homebrew link and unlink

In Homebrew, link and unlink control whether a package’s files are symlinked into your main Homebrew prefix (so they’re available on your PATH).

Creates symlinks for a package into /usr/local (Intel) or /opt/homebrew (Apple Silicon), making it the active version.

brew link <formula>

Common uses:

  • Activate a specific version after installing multiple versions
  • Fix “command not found” after install

Example:

brew link python@3.11

Removes those symlinks, effectively deactivating the package (without uninstalling it).

brew unlink <formula>

Common uses:

  • Avoid conflicts between versions
  • Temporarily disable a tool

Example:

brew unlink python@3.11

⚖️ Switching between versions

A typical workflow:

brew unlink python@3.12
brew link python@3.11

⚠️ Helpful flags

  • Force linking even if conflicts exist:

    brew link --force <formula>
    
  • Overwrite conflicting files:

    brew link --overwrite <formula>
    

🧠 Quick mental model

  • install = download files
  • link = make them usable
  • unlink = hide them (but keep installed)