LinuxCommandLibrary

brew-cleanup

Remove outdated downloads and old package versions

TLDR

Remove outdated downloads and old versions

$ brew cleanup
copy
Preview what would be removed
$ brew cleanup --dry-run
copy
Clean specific formula
$ brew cleanup [formula]
copy
Remove cache files older than specified days
$ brew cleanup --prune=[30]
copy
Scrub cache including latest versions
$ brew cleanup -s
copy
Delete entire cache
$ rm -rf "$(brew --cache)"
copy

SYNOPSIS

brew cleanup [options] [formula|cask]

DESCRIPTION

brew cleanup removes old versions of installed formulae and casks, deletes cached downloads, and frees disk space. It cleans the Cellar and the download cache.
Homebrew automatically performs cleanup after upgrades and periodically every 30 days unless HOMEBREWNOINSTALL_CLEANUP is set.

PARAMETERS

--dry-run, -n

Show what would be removed without removing
--prune days
Remove cache files older than specified days
-s
Scrub cache, including downloads for latest versions
--prune-prefix
Remove empty directories from Homebrew prefix
--formula
Treat all arguments as formulae
--cask
Treat all arguments as casks

CACHE LOCATION

Default cache location: ~/Library/Caches/Homebrew (macOS)
View cache path: brew --cache

RELATED COMMANDS

brew autoremove

Remove unused dependencies
brew upgrade
Should be followed by cleanup

CAVEATS

Old versions are automatically removed during brew upgrade. The -s flag removes even current version downloads which may need re-downloading later. Running without arguments cleans all installed packages.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community