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

Builds faililng due to incorrect dummy files generated for benches

Open lalithsuresh opened this issue 2 years ago • 3 comments
trafficstars

Cargo allows benchmarks to be created with two possible filesystem layouts:

  1. benches/<benchfile.rs>
  2. benches/<benchmark>/{main.rs, <other rust files>}.

See for example: https://github.com/vmware/database-stream-processor/tree/main/crates/dbsp/benches

Using cargo chef on such a project structure creates skeletons of type 1) for benchmark layouts of type 2), causing builds to fail with errors like:

#16 5.600 error: failed to parse manifest at `/app/crates/dbsp/Cargo.toml`
#16 5.600
#16 5.600 Caused by:
#16 5.600   cannot infer path for `ldbc-graphalytics` bench
#16 5.600   Cargo doesn't know which to use because multiple target files found at `benches/ldbc-graphalytics.rs` and `benches/ldbc-graphalytics/main.rs`.
#16 5.601 [cargo-make] ERROR - Error while executing command, exit code: 101
#16 5.601 [cargo-make] WARN - Build Failed.

In this example, benches/ldbc-graphalytics.rs is the created dummy file.

lalithsuresh avatar Apr 14 '23 23:04 lalithsuresh

This is related to https://github.com/LukeMathWalker/cargo-chef/issues/150 and it can be solved by using cargo-metadata for artefact detection rather than our home-grown solution.

Thanks for reporting it!

LukeMathWalker avatar Apr 15 '23 08:04 LukeMathWalker

@LukeMathWalker Using target detection from cargo-metadata is probably useful anyway, but is this specific issue indeed a problem? cargo cook should be invoked from an empty directory containing only recipe.json. In that case, cargo chef will create the wrong benchmark file, but it should be fine for building dependencies.

The problem only happens when user code is copied over and then there are two copies of the same benchmark file, which causes conflicts. Maybe it would be enough to just delete the benches directory after cooking?

Kobzol avatar Apr 18 '23 19:04 Kobzol

@Kobzol that's indeed the workaround I've adopted so far (doing another pass to rm the wrong files).

lalithsuresh avatar Apr 18 '23 19:04 lalithsuresh