How do I find out the dependencies in Cargo.toml that are unused? How can I remove them automatically?
Asked
Active
Viewed 8,281 times
14
-
4It seems like https://github.com/est31/cargo-udeps and/or https://github.com/Bromeon/cargo-machete are your best bets – BallpointBen May 02 '22 at 05:26
-
Looks like cargo-machete is gone now. – Jk Jensen Aug 24 '22 at 21:48
-
You can use this [cargo-machete](https://github.com/bnjbvr/cargo-machete) crate instead. – Enoch Chejieh Oct 23 '22 at 12:17
1 Answers
15
One option is to use cargo-udeps.
You can install it via command:
cargo install cargo-udeps --locked
Then, to find unused dependencies in production target:
cargo +nightly udeps
To find unused dev dependencies:
cargo +nightly udeps --all-targets