cargo-machete icon indicating copy to clipboard operation
cargo-machete copied to clipboard

Remove unused deps from workspace Cargo.toml

Open utkarshgupta137 opened this issue 2 years ago • 9 comments

Currently, cargo-machete doesn't check if the workspace Cargo.toml contains any unused deps or not. I think it should be straightforward as you only need to deal with Cargo.toml files, although things never are.

utkarshgupta137 avatar Jul 18 '23 20:07 utkarshgupta137

@bnjbvr any idea on this issue?

tisonkun avatar Oct 30 '24 10:10 tisonkun

Yep, it's not implemented; one would need to scan the set of dependencies from the workspace, and then figure out the workspace definition to navigate through all the directories it includes. Good luck :-)

bnjbvr avatar Oct 30 '24 12:10 bnjbvr

Hi, is there any progress?

HaoYang670 avatar Mar 10 '25 10:03 HaoYang670

Nope, no one has volunteered to work on this, so feel free to take a stab and open a PR!

bnjbvr avatar Mar 10 '25 10:03 bnjbvr

Removing a dependency with cargo remove will clean all unused dependencies in workspace Cargo.toml.

TD-Sky avatar Mar 10 '25 15:03 TD-Sky

Removing a dependency with cargo remove will clean all unused dependencies in workspace Cargo.toml.

No I don't think so. cargo remove needs user to provide the name of dependency to remove. It cannot find unused deps.

HaoYang670 avatar Mar 11 '25 02:03 HaoYang670

Removing a dependency with cargo remove will clean all unused dependencies in workspace Cargo.toml.

No I don't think so. cargo remove needs user to provide the name of dependency to remove. It cannot find unused deps.

You can give a try. That is the side effect of removing package.

TD-Sky avatar Mar 11 '25 02:03 TD-Sky

cargo-shear seems to have support for removing the dependencies from the workspace Cargo.toml, although I've not looked at how it is doing it.

utkarshgupta137 avatar Aug 14 '25 22:08 utkarshgupta137

Sweet, I didn't know about cargo-shear! Looks like there are a few good ideas to borrow from there…

bnjbvr avatar Aug 15 '25 11:08 bnjbvr