Cargo, Go and pip Are Hoarding 40 GB Between Them
Rust target directories, the Go module cache, pip wheels and abandoned virtualenvs. The language toolchain caches nobody thinks about, and the commands to clear each one.
Xcode and Docker get the blame because they are enormous and obvious. The language toolchains are quieter and add up to more than people expect — 20–40 GB is common on a machine that has run more than one stack.
Check all of them at once:
du -sh ~/.cargo ~/go/pkg/mod ~/Library/Caches/pip ~/.rustup 2>/dev/null | sort -hr
Rust — the biggest of the three, by a distance
Cargo has two separate hoards, and the larger one is not where people look.
target/ directories
Cargo puts build artefacts inside each project, not in a shared location. A mid-sized project’s
target/ is routinely 3–8 GB, and every project you have ever built has one.
Find the real ones — checking for Cargo.toml alongside, because plenty of unrelated projects have
a folder called target:
find ~ -type d -name target -prune 2>/dev/null \
| while read -r d; do
[ -f "$(dirname "$d")/Cargo.toml" ] && du -sh "$d"
done | sort -hr
Clear one properly from inside the project:
cargo clean
Or just delete the directory — cargo clean does the same thing with more ceremony. Everything
rebuilds from source. The cost is one slow compile.
If you build Rust regularly, cargo-sweep removes only
artefacts from toolchain versions you no longer use, which keeps the current build warm:
cargo install cargo-sweep
cargo sweep --installed -r ~
The registry cache
Downloaded crate sources and their compiled .crate archives, shared across projects:
du -sh ~/.cargo/registry/*
~/.cargo/registry/cache holds the downloaded archives and src holds them unpacked. Both are
re-fetchable:
rm -rf ~/.cargo/registry/cache ~/.cargo/registry/src
cargo-cache does this with more precision and a
useful breakdown:
cargo install cargo-cache
cargo cache --autoclean
Old toolchains
rustup keeps every toolchain you ever installed — around 1.5 GB each:
rustup toolchain list
du -sh ~/.rustup/toolchains/*
rustup toolchain uninstall <old-toolchain>
Nightlies accumulate especially fast if you ever pinned a dated one.
Go — one command, no thinking required
The module cache is a single shared directory and it only grows:
du -sh ~/go/pkg/mod
go clean -modcache
Frequently 5–20 GB. Everything re-downloads on the next go build, and Go is fast at it. There is no
downside beyond bandwidth.
Two more worth checking:
# Compiled package and test binaries
du -sh ~/Library/Caches/go-build
go clean -cache
# Fuzzing corpora, if you have ever run go test -fuzz
du -sh ~/Library/Caches/go-build/fuzz 2>/dev/null
go clean -fuzzcache
go clean -cache will make your next build noticeably slower, so clear the modcache first and only
touch the build cache if you still need the space.
Python — the messy one
Python’s problem is not one big cache, it is fragmentation.
pip’s wheel cache
du -sh ~/Library/Caches/pip
pip cache purge
Usually 1–5 GB. Harmless to clear.
Abandoned virtualenvs
This is where the real space is, and it is scattered across every project you have ever started:
find ~ -type d \( -name "venv" -o -name ".venv" -o -name "env" \) -prune 2>/dev/null \
| while read -r d; do
[ -f "$d/pyvenv.cfg" ] && du -sh "$d"
done | sort -hr | head -30
The pyvenv.cfg check is important — it is what distinguishes a real virtualenv from some unrelated
folder called env, and you do not want to delete the second kind.
Each environment is 200 MB to 2 GB, and one carrying PyTorch or TensorFlow can pass 5 GB on its own.
They are entirely reproducible if the project has a requirements.txt, a pyproject.toml or a lock
file. Check that first, then delete freely.
uv, conda, poetry
du -sh ~/.cache/uv 2>/dev/null && uv cache clean
du -sh ~/Library/Caches/pypoetry 2>/dev/null && poetry cache clear --all .
du -sh ~/miniconda3 ~/anaconda3 2>/dev/null && conda clean --all
Conda deserves special attention. A full Anaconda install is 5+ GB before you create a single environment, and each environment is another 2–5 GB. If you installed it for one tutorial, that is worth checking.
Model and dataset caches
If you have touched machine learning at all, this is likely the largest thing on your disk and it is in none of the lists above:
du -sh ~/.cache/huggingface 2>/dev/null
du -sh ~/.ollama/models 2>/dev/null
du -sh ~/.cache/torch 2>/dev/null
Single model weights run to tens of gigabytes. One casual afternoon with Ollama can leave 60 GB behind. These re-download, but slowly and over a lot of bandwidth — so unlike everything else in this article, think before you clear them.
Everything, in one pass
# Rust
cargo cache --autoclean 2>/dev/null || rm -rf ~/.cargo/registry/cache ~/.cargo/registry/src
# Go
go clean -modcache
# Python
pip cache purge
# Node
npm cache clean --force
# Homebrew
brew cleanup -s --prune=all
Ten to forty gigabytes on a typical polyglot machine, and every byte of it re-downloadable.
The rest is in the full developer storage guide — Xcode, Docker, Android and node_modules are all larger than anything here.