DEV Community

Masato Ohba
Masato Ohba

Posted on • Edited on

8 3

brew cleanup might save your disc space

Do you use Homebrew on macOS? And are you in trouble with low disc space?

Then just try brew cleanup.

Overview

Since brew does not automatically remove old formulae, your installed packages pile up and press your disc.

Following the official FAQ, I tried brew cleanup and got about 4 GB of free space in my case.

Usage

The official page introduces very few samples.

# remove a formula
$ brew cleanup <formula>

# clean up everything at once
$ brew cleanup

# see what would be cleaned up
$ brew cleanup -n
Enter fullscreen mode Exit fullscreen mode

For further information, let's see help.

$ 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)
Enter fullscreen mode Exit fullscreen mode

Now we got something new.

  • --prune=days can destroy caches N days or earlier. Although it lacks description about a case when we omit this option, it defaults to 14 days by reading code.
  • -n is an abbreviation of --dry-run.
  • we can clean up even the latest formula with -s.

Further details

If you want to dive into it more, reading code is the best way.

Concerned about the future of the software development career?

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Okay let's go

Community matters

Top comments (1)

Collapse
 
elmatadito profile image
Jonathan Romero

Thank you! You save me :P

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay