How to clean Homebrew cache and old versions

Homebrew keeps downloaded bottles, stale locks, and older formula versions so installs and upgrades can reuse local files. Cleaning that state reclaims disk space after package churn while leaving the currently installed package versions in place.

brew cleanup removes stale lock files, outdated formula and cask downloads, and old versions under the Homebrew prefix. By default, downloads older than 120 days are eligible; HOMEBREW_CLEANUP_MAX_AGE_DAYS changes that age, and --prune=all expands cache cleanup to every cached download.

Review the dry-run output before deleting anything on a workstation with pinned packages, local builds, or limited network access. Removing cached downloads does not uninstall current packages, but future installs or reinstalls may need to download the same bottles again.

Steps to clean Homebrew cache and old versions:

  1. Review the standard Homebrew cleanup plan.
    $ brew cleanup --dry-run
    Would remove: /opt/homebrew/Cellar/wget/1.25.0 (19 files, 4.2MB)
    Would remove: /Users/alex/Library/Caches/Homebrew/wget--1.25.0.bottle.tar.gz (1.6MB)
    ==> This operation would free approximately 5.8MB of disk space.

    --dry-run shows the files and directories that would be removed. No output means standard cleanup has no candidates.

  2. Limit cleanup to one reviewed formula or cask when the global list is too broad.
    $ brew cleanup wget
    Removing: /opt/homebrew/Cellar/wget/1.25.0... (19 files, 4.2MB)
    ==> This operation has freed approximately 4.2MB of disk space.

    Passing a package name cleans only that formula or cask plus its eligible cache entries.

  3. Run standard cleanup after reviewing the dry-run list.
    $ brew cleanup
    Removing: /Users/alex/Library/Caches/Homebrew/wget--1.25.0.bottle.tar.gz... (1.6MB)
    ==> This operation has freed approximately 1.6MB of disk space.

    Do not run cleanup while another brew install, brew upgrade, or brew uninstall is changing Homebrew state.

  4. Review full cache pruning only when every cached download can be discarded.
    $ brew cleanup --prune=all --dry-run
    Would remove: /Users/alex/Library/Caches/Homebrew/node--24.4.1.bottle.tar.gz (18.4MB)
    ==> This operation would free approximately 18.4MB of disk space.

    --prune=all removes cache files that standard cleanup may keep for reuse. Use it only when re-downloading packages later is acceptable.

  5. Apply the reviewed full cache prune.
    $ brew cleanup --prune=all
    Removing: /Users/alex/Library/Caches/Homebrew/node--24.4.1.bottle.tar.gz... (18.4MB)
    ==> This operation has freed approximately 18.4MB of disk space.
  6. Verify that standard cleanup has no remaining candidates.
    $ brew cleanup --dry-run

    No output means Homebrew has nothing left to remove under the standard cleanup rules. Use brew cleanup with --prune=all and --dry-run again if a full cache prune was part of the cleanup.