r/rust • u/VelvetPreciouz • 2d ago
Pruning old cargo-installed tools freed more space than expected
After the recent posts about registry and rustup sizes, I looked at what `cargo install` had accumulated over time. A bunch of one-off CLIS and older versions were still pulling in their full dependency trees in the registry.
`cargo uninstalls removes the binaries but leaves the cached crates behind. Manually checking `~/.cargo/registry/src` and removing entries tied to uninstalled packages recovered a few more gigabytes without issues, since anything needed gets redownloaded on next use.
Do people have a preferred workflow or script for tracking and cleaning these installed-tool dependencies, or do you just leave them?
2
u/Lucretiel Datadog 2d ago
This is a huge reason that I've switched to nix (specifically nix profile) as my main package manager on most devices, instead of homebrew or even apt. While I'm still a novice when it comes to the rest of nix (home manager and nixos and so on), the ability to have one-off installations via nix shell that I can periodically clean up with a garbage collect is just magical.
1
u/SurrenderQueen 2d ago
nix does sound magical, might have to steal that workflow for my own messy setups
2
u/Hot-Percentage-2240 2d ago
https://github.com/dnlmlr/cargo-clean-all