#cargo #cache #cleanup #cargo-lock #cargo-subcommand #cli

app cargo-cleanup

Reads Cargo.lock and prints all cached package versions not mentioned inside

3 releases

Uses old Rust 2015

0.1.2 Oct 18, 2018
0.1.1 Oct 18, 2018
0.1.0 Oct 17, 2018

#705 in Cargo plugins

37 downloads per month

Apache-2.0/MIT

8KB
83 lines

Cached package cleanup for Cargo

Cargo keeps a local cache of downloaded dependencies. Over time, as dependencies are updated, this cache can grow pretty large, and full of outdated package versions which are unlikely to be used ever again. This tool can help you discover which packages are no longer needed. In the present, proof-of-concept form, only packages published on crates.io and present in the default registry are considered, and no automatic deletion is supported.

Installation

$ cargo install cargo-cleanup

Usage

Run

$ cargo cleanup

in the top-level directory of some crate. This will automatically try to use Cargo.lock from that directory. (Alternatively, you can specify the path of Cargo.lock as an argument to the command.) The program will read the names and versions of all dependencies, then scan the Cargo unpacked crate cache ($HOME/.cargo/registry/src/*/...) and list the packages whose names are in the list, but versions aren't. For example, if your crate uses rand-0.3.22 and rand-0.4.3, and the cache contains those two plus rand-0.5.5, only rand-0.5.5 will be listed.

Caveat

This is a proof of concept. There is no automatic deletion. Packages retrieved directly from their repositories are not considered. Neither are alternative registries.

License

Licensed under either of:

at your option.

Dependencies

~0.7–1.5MB
~30K SLoC