Doesn't work with workspace inheritance of package.edition
Veetaha opened this issue · 3 comments
When running cargo-machete
with workspace inheritance the CLI outputs errors. This happens when the package.edition
key is used in the workspace-level manifest and inherited in the package-level manifest. Inheriting other keys doesn't seem to break cargo machete
.
Reproduction
You may use the reproduction git repository:
git clone git@github.com:Veetaha/cargo-machete-workspace-inheritance-bug-repro.git
cd cargo-machete-workspace-inheritance-bug-repro
cargo machete
cargo machete --with-metadata
You'll see that both cargo machete
invocations fail
~/dev/cargo-machete-workspace-inheritance-bug-repro (master) $ cargo machete
Analyzing dependencies of crates in this directory...
error when handling /home/veetaha/dev/cargo-machete-workspace-inheritance-bug-repro/foo/Cargo.toml: value from workspace hasn't been set
cargo-machete didn't find any unused dependencies in /home/veetaha/dev/cargo-machete-workspace-inheritance-bug-repro. Good job!
Done!
~/dev/cargo-machete-workspace-inheritance-bug-repro (master) $ cargo machete --with-metadata
Analyzing dependencies of crates in this directory...
error when handling /home/veetaha/dev/cargo-machete-workspace-inheritance-bug-repro/foo/Cargo.toml: value from workspace hasn't been set
cargo-machete didn't find any unused dependencies in /home/veetaha/dev/cargo-machete-workspace-inheritance-bug-repro. Good job!
Done!
Or you can create the cargo workspace manually the following way.
Workspace-level Cargo.toml
manifest:
workspace.members = ["foo"]
workspace.package.edition = "2021"
Package-level Cargo.toml
manifest:
[package]
name = "foo"
version = "0.1.0"
edition = { workspace = true }
Meta
CLI version is 0.4.0
. Suprisingly, there is no --version
command in the CLI.
Yep, it's a bug in the cargo_toml library, unfortunately, as proves this test case adapted from yours: https://github.com/bnjbvr/cargo-toml-workspace-inheritance-bug-repro
running cargo run
from the top-level directory will show the same error. I'll open an issue on cargo_toml's issue tracker.
Thanks for reporting!
CLI version is 0.4.0. Suprisingly, there is no --version command in the CLI.
Feel free to implement this! I've pushed as far as I could adding a library to parse arguments, maybe the time has come :)
Looks like the 0.5.0 version fixes this. Confirmed by testing in my repo. Thanks!