Closed sdroege closed 38 minutes ago
FWIW, I ran into this when trying to work around https://github.com/rust-lang/cargo/issues/13447 by simply placing a examples/dummy.rs
into all crates that don't have any example to force the publishing of its Cargo.lock
.
Thanks for the report! This is a known issue, and if you build both examples at the same time you should get a warning of warning: output filename collision.
along with an explanation. Since this is tracked in #6313, closing as a duplicate of that.
Thanks, sorry for missing that. Searched for the wrong keywords apparently :)
Problem
If a cargo workspace contains multiple member crates that have an example with the same name then the executable of that example is stored place for all of them.
Steps
$ cargo build -p a --example dummy
$ cargo build -p b --example dummy
Note that
target/debug/examples/dummy
andtarget/debug/examples/dummy.d
is used by both crates. That's obviously not optimal because only one example can exist at a time like this, but it also means that parallel builds on Windows fail randomly with a linker error if both crates are built in parallel and twolink.exe
are trying to accesstarget/debug/example/dummy.exe
at the same time.Possible Solution(s)
Store examples in subdirectories based on the crates they're from
Notes
No response
Version
cargo 1.82.0 (8f40fc59f 2024-08-21) release: 1.82.0 commit-hash: 8f40fc59fb0c8df91c97405785197f3c630304ea commit-date: 2024-08-21 host: x86_64-unknown-linux-gnu libgit2: 1.8.1 (sys:0.19.0 vendored) libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w) ssl: OpenSSL 1.1.1w 11 Sep 2023 os: Fedora 41.0.0 [64-bit]