LukeMathWalker / LukeMathWalker/cargo-chef
cargo-chef 0.1.69 produces duplicate target in `xplr` crate
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.7k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
For context, we use cargo-chef for building Rust packages in [Brioche](https://brioche.dev/) (see [`rust/package.bri`](https://github.com/brioche-dev/brioche-packages/blob/ff64f2d8edc4e814c0c419aae5f497ddc6f7c359/packages/rust/project.bri#L217)). After we upgraded from cargo-chef v0.1.68 to v0.1.70, our build of the package [xplr](https://github.com/sayanarijit/xplr) started failing. I was able to reproduce it locally by checking out [xplr@a82ea6a](https://github.com/sayanarijit/xplr/tree/a82ea6a3e5eb9bb2e528d2a3320056acfe312101) and using cargo-chef like this:
```sh
cargo chef prepare --recipe-path recipe.json
cargo chef cook --recipe-path recipe.json --no-build
```
I narrowed it down to a regression introduced in 0.1.69. Between 0.1.68 and 0.1.69, cargo-chef started introducing a duplicate `[[examples]]` target within `Cargo.toml`. Here's a diff between the `Cargo.toml` produced by cargo-chef between 0.1.68 and 0.1.69:
```diff
diff --git a/Cargo.toml b/Cargo.toml
index b4459a8..7d69c39 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,10 +1,11 @@
-test = []
-
[[bin]]
+path = "src/bin/xplr.rs"
name = "xplr"
plugin = false
proc-macro = false
+edition = "2021"
required-features = []
+crate-type = ["bin"]
[[bench]]
path = "./benches/criterion.rs"
@@ -12,7 +13,18 @@ name = "criterion"
plugin = false
proc-macro = false
harness = false
+edition = "2021"
+required-features = []
+crate-type = ["bin"]
+
+[[bench]]
+path = "benches/criterion.rs"
+name = "criterion"
+plugin = false
+proc-macro = false
+edition = "2021"
required-features = []
+crate-type = ["bin"]
[[example]]
path = "examples/run.rs"
@@ -21,6 +33,7 @@ plugin = false
proc-macro = false
edition = "2021"
required-features = []
+crate-type = ["bin"]
[package]
name = "xplr"
@@ -120,7 +133,7 @@ plugin = false
proc-macro = false
edition = "2021"
required-features = []
-crate-type = ["rlib"]
+crate-type = ["lib"]
[profile.release]
lto = true
```
This duplicate section causes Cargo commands to fail with the following error:
```
error: failed to parse manifest at `/path/to/xplr/Cargo.toml`
Caused by:
found duplicate bench name criterion, but all bench targets must have a unique name
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the regression in the xplr crate using cargo-chef 0.1.68 and 0.1.69 with the shown prepare and cook commands, then compare the generated Cargo.toml files. Trace how cargo-chef generates target sections and verify that the resulting manifest no longer contains duplicate bench targets before rerunning the commands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100