Skip to content
Package Managers & Toolchains

How to Clean Homebrew, Cargo & Gradle Caches on Mac

Whenever you run 'brew upgrade', 'cargo build', or './gradlew test', your toolchains quietly store multi-gigabyte package archives and precompiled binaries on your SSD. Here is how to safely recover 20–50 GB without breaking active projects.

October 20265 min read

Where Package Managers Hide Tens of Gigabytes

Developer package managers are optimized for speed, which means they prefer hoarding downloaded tarballs, wheels, and crate archives rather than deleting them. Over a year of active development, these caches routinely cross 30+ GB.

# Check how much space your package managers are consuming right now: du -sh ~/Library/Caches/Homebrew 2>/dev/null du -sh ~/.cargo/registry 2>/dev/null du -sh ~/.gradle/caches 2>/dev/null du -sh ~/Library/Caches/pip 2>/dev/null

1. Cleaning Homebrew Bottle Archives (10–25 GB)

Homebrew keeps downloaded bottle binaries in ~/Library/Caches/Homebrew/ even after installing them. Standard brew cleanup often leaves files younger than 120 days.

To run a full, deep purge of all downloaded bottles and old formula logs:

# Dry-run first to preview reclaimed space: brew cleanup -n -s # Purge all cached downloads immediately: brew cleanup --prune=all -s # Remove all downloaded git clone caches: rm -rf $(brew --cache)

2. Purging Rust Cargo Crate Caches (5–20 GB)

Cargo stores every downloaded crate version indefinitely inside ~/.cargo/registry/cache/. If you work on several Rust projects or frequently upgrade dependencies, this directory balloons rapidly.

You can safely purge downloaded .crate tarballs and git checkouts. Cargo will redownload any required dependencies during your next build:

# Purge downloaded crate archives: rm -rf ~/.cargo/registry/cache/* # Clean git repo checkouts for crates: rm -rf ~/.cargo/git/checkouts/*

3. Pruning Gradle & Python pip Artifacts (5–15 GB)

If you develop Android apps or work with Java/Kotlin, Gradle leaves gigabytes of old distributions and daemon logs in ~/.gradle. Similarly, Python pip caches wheel files forever.

# Clear Python pip wheel cache: pip cache purge 2>/dev/null || rm -rf ~/Library/Caches/pip # Clean unused Gradle wrapper distributions: rm -rf ~/.gradle/wrapper/dists/* # Stop daemons and clean Gradle build cache: rm -rf ~/.gradle/caches/build-cache-1/*

4. Manage All Toolchains in One Screen with SpaceWise

Rather than memorizing different CLI flags for Homebrew, Cargo, Gradle, CocoaPods, and pip, SpaceWise audits all installed toolchains simultaneously in milliseconds.

It flags stale versions, displays how much SSD space is reclaimable, and lets you wipe toolchain caches in 1 click without ever deleting your active project builds.

Reclaim your Mac's SSD today

Clean toolchains, Docker, Xcode, and node_modules in 1-click with zero telemetry.

Download Free for Mac

Do all of this in SpaceWise — for free

SpaceWise scans and safely cleans everything covered in this guide with one click. No Terminal required.

Download for Mac Free