Incorrect "can't find crate for `foo`" when really the dependency of `foo` is not found.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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
--verboseand note down therustccommand 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
Contributor guide
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 failure with the stated Cargo project, deleted equivalent artifact, and direct rustc command, then examine how rustc reports E0463 when indexmap is present but its transitive dependency is missing. Done means the diagnostic identifies equivalent as the missing dependency of indexmap, while preserving the existing source location and relevant error context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100