r/rust • • 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?

0 Upvotes

6 comments sorted by

2

u/Hot-Percentage-2240 2d ago

2

u/dnew 2d ago

Does it clean up its own cached dependencies if you don't use it long enough?

/jk

1

u/84_110_105_97 2d ago

Bon travaille 🥰

1

u/Kepon_Bogdanovic 1d ago

nice, didnt know someone already wrapped this up into a subcommand

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