-
Notifications
You must be signed in to change notification settings - Fork 2.6k
"can't find crate for..." proc-macro crates when the crate is clearly present and is passed to rustc #15488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
nora ran cargo bisect-rustc and found this:
so a) this is a rustc bug, and b) i suspect it is related to rustc-stable-hash somehow. we also ran RUSTC_LOG=rustc_metadata=info and found this mismatch between the working and non-working builds:
|
this bit here: https://github.com/rust-lang/rust/blob/c9f690a1e3d42f80788e9e4f2aa25547b1d8df58/compiler/rustc_metadata/src/creader.rs#L516-L535 |
there is additional logging in the non-working case that i didn't post at first; here it is:
in particular note those last two lines. "register newly loaded library" should always be followed by "register crate"; the only way it can go wrong is if my working theory:
cc @petrochenkov @Urgau i suspect this is related to rust-lang/rust#127479 somehow but i'm not sure how. do you have ideas on what could be going wrong in |
i think there is a secondary issue which is that this should have reported E0519 instead of "crate not found". the last code to touch that was rust-lang/rust#111461 but that says it was just readding existing logic. |
ok yeah rust-lang/rust#109213 really should not have removed the |
I re-examine rust-lang/rust#127479 and I don't see anything that would explain the behavior seen here. I also re-compared the extracted code with the code inside rustc-stable-hash and didn't find any meaningful difference. @jyn514 Are you able to confirm that the crate hash are not the same? Does reverting the PR fixes the issue? |
@Urgau i'm not able to replicate this locally, so i can't confirm anything about the hashes one way or another. but i don't see anything else in the range bisect-rustc shows that could possible affect metadata loading. and the error seems related to hashing somehow, because the issue is that rustc_resolve thinks the .so file doesn't match the already loaded cnum, even though later it errors because file has the same StableCrateId. |
I tried locally and on a VM and I'm also unable to reproduce it, with both |
Do you have the Nix package manager installed? I am using Nix on Ubuntu and ran into a similar issue with |
I bumped into this a couple of times with nixpkgs but never remembered how I fixed it. Guess it might be nix patch-elf at sometimes patching rustc wrongly, or my rust toolchain frkm nixpkgs was missing some dependencies. |
if someone encountering this problem could run |
Removing the home-manager managed |
Problem
When compiling some crates (
poem
3.1.10,salvo
0.78.0), I expect them to build; they fail to build with errors like:Steps
cargo new whatever && cd whatever
cargo add poem
(orsalvo
)cargo build
However, I tried this on a new VM and wasn't able to reproduce it. It's something to do with my system, and I haven't yet figured out what.
Possible Solution(s)
I tried uninstalling (
rustup self uninstall
) and reinstalling Rust, as well ascargo clean
andrm -r ~/.cargo/registry/cache
.This appears not to happen under rust 1.80 but does happen under 1.81.
Notes
I ran
cargo build --verbose
and can see that the "missing" crates are indeed being passed to rustc:Version
The text was updated successfully, but these errors were encountered: