Open nipunn1313 opened 11 months ago
Thanks for opening an issue. I, for one, quite like that I could run the tool independently of workspaces in a directory that contained multiple Rust projects (unrelated to each other, i.e. no workspaces). And it'd be an API breaking change. So maybe we can introduce a CLI flag that respects the workspace
by default.
Out of curiosity, you're saying it's useful in monorepos. Right now cargo-machete
will look only for Cargo.toml
file, so it only depends on the number of directories; do you see a large difference in runtime, when comparing:
How about: find all Cargo.toml
files at or below the current working directory, but to not crawl subdirectories if a Cargo.toml
is found. Instead call cargo-metadata
to find the workspace members and check those.
On problem I have now is that generated crates in the target
directory also get checked. For example, trybuild
generates a crate to run compile-fail tests. These may easily end up using less dependencies, but the generated crate copies all dependencies, just in case.
Alternatively, but more difficult I think: find all Cargo.toml
files, but ignore target
directories of workspaces. However, this still requires something like cargo-metadata
to correctly identify the target
directory.
https://doc.rust-lang.org/cargo/reference/workspaces.html#the-members-and-exclude-fields
For example if the workspace Cargo.toml has
Then ideally cargo-machete only searches the
crates/
andcrates_private/
directories. This is particularly useful in monorepos where there are a large number of files not included in the workspace.Thanks for the tool - it's great!