brew cleanup might save your disc space
Masato Ohba
Apr 3
Updated on Apr 07, 2018
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
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)
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.
Did you find this post useful? Show some love!
dev.to is where software developers stay in the loop and avoid career stagnation.
Signing up (for free!) is the first step.
Classic DEV Post from Oct 20 '17
Hey there, we see you aren't signed in.
Please consider creating an account on dev.to. It literally takes a few seconds and we'd appreciate the support so much. ❤️