bnjbvr / cargo-machete

Remove unused Rust dependencies with this one weird trick!
MIT License
781 stars 28 forks source link

Hall Of Fame :sparkles: #6

Open bnjbvr opened 2 years ago

bnjbvr commented 2 years ago

If cargo-machete has been useful for you and has helped removing dependencies in your project, feel free to add a comment to this issue :)

dmerejkowsky commented 2 years ago

https://git.sr.ht/~dmerej/skyspell/commit/722c4eeb302df160d5dc973f571516b03699e9a5

It works !

Veetaha commented 2 years ago

I applied it in a really large cargo workspace in our private repository and it detected like really many unused crates for us! Our workspace is around 122 crates, and we managed to remove ~187 unused dependencies :tada:!

However, the number of false positives was ~67.

The main problem is that we use a lot of code included from OUT_DIR, which isn't analyzed.

Also, cargo-machete --with-metadata doesn't analyze build.rs tests and other rust files from examples/ directory (also, I am not sure but maybe benches/ directory is not analyzed either?) for some reason (is it broken?)

Also, looks like pub use ::crate_name reference doesn't seem to be picked up by cargo-machete

Bromeon commented 2 years ago

https://github.com/godot-rust/godot-rust/pull/890 (revision 84c99b1)

bnjbvr commented 2 years ago

Also, looks like pub use ::crate_name reference doesn't seem to be picked up by cargo-machete

Ah, looks like an oversight, will add a test and support for that, thanks!

mickvangelderen commented 2 years ago

I've used cargo-machete alongside cargo-udeps to quickly find and remove unneeded dependencies after splitting one crate into multiple crates. I had to manually add some exceptions for dependencies of code generated through build scripts as well but other than that worked great.

xxchan commented 1 year ago

https://github.com/risingwavelabs/risingwave/pull/7816 It helped a lot! Thanks for the great tool. Tens of udeps are removed.

The commit history in this PR also shows how I used it and the problems I met:

Also, cargo-machete --with-metadata reports something like error: current package believes it's in a workspace when it's not. It may be because we wrongly configured some crates, but I didn't bother to fix it. Fortunately it turns out there aren't many false-postives.

azzamsa commented 1 year ago

I'm facing difficulties while trying to install cargo-udeps, as it seems to depend on libssl.so.1.1. I've already installed several SSL-related dependencies on both Ubuntu 22.04 and Debian 12, but I haven't been successful so far.

As a last resort, I'm considering installing libssl.so.1.1 on an Arch container using Distrobox. However, I'm also open to exploring alternatives. Surprisingly, cargo-machete managed to find what cargo-udeps couldn't. 🏆

monorepo-services/alibaba on  alibaba/refactor [!?] is 📦 v0.4.0 via 🦀 v1.71.0
# `cargo-udeps`
    Checking hyosho v0.4.0 (/home/user/projects/monorepo-services/alibaba)
    Finished dev [unoptimized + debuginfo] target(s) in 1.63s
info: Loading depinfo from "/home/user/projects/monorepo-services/alibaba/target/debug/deps/hyosho-14768cb6b
da7830f.d"
info: Loading depinfo from "/home/user/projects/monorepo-services/alibaba/target/debug/deps/hyosho-bc29a72ec
262bf2e.d"
All deps seem to have been used.

# `cargo-machete`
Analyzing dependencies of crates in this directory...
cargo-machete found the following unused dependencies in /home/user/projects/monorepo-services/alibaba:
hyosho -- /home/user/projects/monorepo-services/alibaba/Cargo.toml:
        rand
        url
Done!
randombit commented 9 months ago

A colleague used cargo machete to remove dozens of unused dependencies from our project

https://github.com/dfinity/ic/commit/a3b6bebfe3ba5c296f964d51c771113fff47f575

Thank you!!

poliorcetics commented 8 months ago

No public code to show off but cargo machete worked like a charm and managed to find 2 unused deps (including one on an internal crate) which let me remove a build-script, always nice for small compile times wins 🎉

kvark commented 8 months ago

I finished cleaning up Zed - https://github.com/zed-industries/zed/pull/8468 In a series of 4 PR, around 600 LOC were removed from Cargo.lock with many unused dependencies. In the meantime,

And cargo-udeps shows me that All deps seem to have been used., now I'm convinced to remove it.

torokati44 commented 7 months ago

I has been useful, yes: https://github.com/ruffle-rs/ruffle/pull/15774 :)

IgnisDa commented 4 months ago

Been using cargo machete for https://github.com/IgnisDa/ryot for over a year. Really useful tool.

Also love the name!

larseggert commented 3 months ago

https://github.com/mozilla/neqo/pull/1974