When sharing CARGO_TARGET_DIR
, cargo
does not distinguish between 2 path deps with the same name/version
#12516
Labels
A-rebuild-detection
Area: rebuild detection and fingerprinting
C-bug
Category: bug
S-needs-design
Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Problem
When one sets
CARGO_TARGET_DIR
to a directory shared between different workspaces, if those workspaces include crates that are path dependencies with the same name and version and relative-to-the-workspace-path (ie: from the root of the workspace, these crates are in the same place, even though in system-wide terms they are separate directories), cargo treats these 2 crates as the same.This results in potentially unexpected crates being combined for anyone using a shared
CARGO_TARGET_DIR
.Steps
I've made a repo showing the issue here: https://github.com/jmesmon/cargo-rebuild-bug
Running
./test.sh
does 2 cargo builds: cratesa
andb
with a sharedCARGO_TARGET_DIR
.a
has a path dependency onc
(located ata/c
).b
has a path dependency onc
(located atb/c
). The crate ina/c
has anpub unsafe fn c() -> u32
, whileb/c
has apub fn c() -> u32
(ie: safe). This fails on the second build when it tries to buildb
, which should depend onb/c
, but instead tries to usea/c
, and an error about calling an unsafe function is emitted../test-working.sh
shows the same 2 crates built without sharing aCARGO_TARGET_DIR
.Possible Solution(s)
Plausible that the metadata for
path
crates (relative to a parent crate/workspace) needs to include some extra info, perhaps some part of path (or a fully resolved path) that would be sufficient to distinguish them.Alternately, one might at least ensure a rebuild occurs (but still possibly break some things) by detecting that the content of
a/c
andb/c
don't match, triggering a rebuild.Notes
No response
Version
The text was updated successfully, but these errors were encountered: