Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

brew cleanup
brew cleanup

What is Brew cleanup?

Educative Answers Team
svg viewer

Homebrew is a free, open-source software package management system that simplifies the installation of software on Apple’s macOS operating system and Linux. Homebrew is written in the Ruby programming languageRuby is an interpreted, high-level, general-purpose programming language used for building webpages.. By default, Homebrew is installed into location /usr/local and consists of a git repository. Any user can update Homebrew using an updated repository from GitHub.

By default, Homebrew does not uninstall old versions of a formula so, over time, you will accumulate old versions.

Since Homebrew does not remove old formulae automatically, some of the installed packages may pile up on our discs and compromise memory. If you are a macOS or Linux user and you also use Homebrew, there is a chance that you may have trouble dealing with low disk space. In this case, use brew cleanup to free up space.

svg viewer

Brew cleanup

Brew cleanup frees up space in macOS and Linux devices by removing old versions of formulae and small kegs of data (about 20-80 MB each). Let’s look at sample instructions:

# remove a formula
$ brew cleanup <formula>

# clean everything up at once
$ brew cleanup

We can access “help” using -h.

$ brew cleanup -h

brew cleanup [--prune=days] [--dry-run] [-s] [formulae]:
    For all installed or specific formulae, remove any older versions from the cellar. In addition, old downloads from the Homebrew download-cache are deleted.

    If --prune=days is specified, remove all cache files older than days.

    If --dry-run or -n is passed, show what would be removed, but do not actually remove anything.

    If -s is passed, scrub the cache, removing downloads for even the latest versions of formulae. Note downloads for any installed formulae will still not be deleted. If you want to delete those too: rm -rf $(brew --cache)
  1. Command -prune=days can clear caches of some days N earlier. If the number of days is​ not provided, then it will clear caches of the previous 14 days.

  2. Command s can be used to clean the latest formula.


brew cleanup
brew cleanup
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring