Rust macro crate: can't find crate, import resolution is stuck

434 views Asked by At

When I try to build my application on one specific machine, I get the following error:

error[E0463]: can't find crate for `custom_crate`
 --> examples/basic/src/main.rs:4:5
  |
4 | use custom_crate::custom_macro;
  |     ^^^^^^^^^^^^^^^^ can't find crate

error: cannot determine resolution for the attribute macro `custom_macro`
 --> examples/basic/src/main.rs:6:3
  |
6 | #[custom_macro("test")]
  |   ^^^^^^
  |
  = note: import resolution is stuck, try simplifying macro imports
  • custom_crate is a proc macro lib that I've imported with path= in Cargo file.
  • I am using rustc and cargo 1.74.0. I installed with rustup toolchain.
  • The problematic server uses Ubuntu 20.04.6.

I am confident that my file structure is correct, as it works on every other virtual or physical machine I've tried with the same Rust/compiler versions, code, etc.

  • E.g., macro and app are in different crates, macro is exported, macro is included as a dependency with correct path, etc.

The workaround here did not work (and also should not be happening in 1.74.0?): https://github.com/rust-lang/rust/issues/57966

I tried reinstall/uninstall and running build as root. Tried cargo add with the crate.

Stuck on other things to try. Are there known issues with, for example, env variables or this version of Ubuntu? Again, I don't get this error with every other machine/OS/etc. that I've tried.

Thank you very much!

0

There are 0 answers