Description
Repro
-
Create a test crate that depends on a crate (say
indexmap
) that has some transitive dependencies (sayequivalent
):$ cat Cargo.toml [package] name = "transitive_dep_missing" version = "0.1.0" edition = "2024" [dependencies] indexmap = "2.9.0" $ cat src/main.rs #[allow(unused_imports)] use indexmap::IndexMap; fn main() { println!("Hello, world!"); } $ cargo tree transitive_dep_missing v0.1.0 (/home/lukasza/src/cargo/transitive_dep_missing) └── indexmap v2.10.0 ├── equivalent v1.0.2 └── hashbrown v0.15.4
-
Build the crate normally, but use
--verbose
and note down therustc
command used to build the top-level crate:cargo build --verbose
-
Simulate a bug/error in the build system by trying to build the top-level crate, after deleting one of transitively depended-on crates (this is a simplification of a bug in Chromium builds system - see https://crbug.com/428272362):
$ rm target/debug/*transitive_dep_missing* $ rm target/debug/deps/*equivalent* $ rustc --crate-name transitive_dep_missing --edition=2024 src/main.rs --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=f5cd9e5c1e614061 -C extra-filename=-80b808700c2f7ed4 --out-dir /home/lukasza/src/cargo/transitive_dep_missing/target/debug/deps -C incremental=/home/lukasza/src/cargo/transitive_dep_missing/target/debug/incremental -L dependency=/home/lukasza/src/cargo/transitive_dep_missing/target/debug/deps --extern indexmap=/home/lukasza/src/cargo/transitive_dep_missing/target/debug/deps/libindexmap-ed82d862ae804585.rlib error[E0463]: can't find crate for `indexmap` --> src/main.rs:2:5 | 2 | use indexmap::IndexMap; | ^^^^^^^^ can't find crate error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0463`.
Current output
error[E0463]: can't find crate for `indexmap`
--> src/main.rs:2:5
|
2 | use indexmap::IndexMap;
| ^^^^^^^^ can't find crate
Desired output
error[E0463]: can't find crate for `equivalent` which `indexmap` depends on
--> src/main.rs:2:5
|
2 | use indexmap::IndexMap;
| ^^^^^^^^ can't find crate
or maybe
error[E0460]: found possibly newer version of crate `equivalent` which `indexmap` depends on
--> src/main.rs:1:1
|
1 | extern crate indexmap;
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
crate `equivalent`: /home/lukasza/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libequivalent-a7e65d9ee6e36542.rmeta
crate `indexmap`: /home/lukasza/src/cargo/transitive_dep_missing/target/debug/deps/libindexmap-ed82d862ae804585.rlib
Rationale and extra context
In the repro steps above we have explicitly deleted equivalent
crate's rlib
- this crate is missing. indexmap
's rlib
file is still there.
In https://crbug.com/428272362 the rlib
of the transitive dependency is present, but it is present in another directory and the Chromium's build system seems to have a bug which prevents it from passing -Ldependency=...
and --extern foo=path/to.rlib
for the transitive dependency crate.
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.90.0-nightly (706f244db 2025-06-23)
binary: rustc
commit-hash: 706f244db581212cabf2e619e0113d70999b2bbe
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Anything else?
No response