Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove unused dependencies in Cargo.toml?

How do I find out the dependencies in Cargo.toml that are unused? How can I remove them automatically?

like image 264
z11i Avatar asked Sep 07 '25 04:09

z11i


1 Answers

Update for 2024

As of Sep 2024, this answer requires nightly to run. If you don't want nightly builds, refer to Michael Hall's or Mujeeb Kalwar's answer instead.


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
like image 116
z11i Avatar answered Sep 11 '25 11:09

z11i