Skip to content

"can't find crate for..." proc-macro crates when the crate is clearly present and is passed to rustc #15488

Open
@NoraCodes

Description

@NoraCodes

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:

error[E0463]: can't find crate for `salvo_macros`
  --> /home/nora/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/salvo_core-0.78.0/src/lib.rs:31:9
   |
31 | pub use salvo_macros::handler;
   |         ^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `salvo_macros`
  --> /home/nora/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/salvo_core-0.78.0/src/lib.rs:33:9
   |
33 | pub use salvo_macros as macros;
   |         ^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `salvo_macros`
  --> /home/nora/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/salvo_core-0.78.0/src/lib.rs:85:13
   |
85 |     pub use salvo_macros::{Extractible, handler};
   |             ^^^^^^^^^^^^ can't find crate

For more information about this error, try `rustc --explain E0463`.
error: could not compile `salvo_core` (lib) due to 3 previous errors

Steps

  1. cargo new whatever && cd whatever
  2. cargo add poem (or salvo)
  3. 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 as cargo clean and rm -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:

/home/nora/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc 
--crate-name salvo_core 
--edition=2024 /home/nora/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/salvo_core-0.78.0/src/lib.rs 
# ...
--extern salvo_macros=/tmp/salvotest/target/debug/deps/libsalvo_macros-2d16cc326ba6665d.so 
# ...
--cap-lints allow`

Version

cargo 1.86.0 (adf9b6ad1 2025-02-28)
release: 1.86.0
commit-hash: adf9b6ad14cfa10ff680d5806741a144f7163698
commit-date: 2025-02-28
host: x86_64-unknown-linux-gnu
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.12.0-DEV (sys:0.4.79+curl-8.12.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Debian 12.0.0 (bookworm) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions