Skip to content
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

can't find crate for 'XYZ' (windows-msvc only) #15137

Open
newfla opened this issue Feb 3, 2025 · 8 comments
Open

can't find crate for 'XYZ' (windows-msvc only) #15137

newfla opened this issue Feb 3, 2025 · 8 comments
Labels
C-bug Category: bug O-windows OS: Windows S-triage Status: This issue is waiting on initial triage.

Comments

@newfla
Copy link

newfla commented Feb 3, 2025

Hi,
I'm unable to build the diffusion-rs library using x86_64-pc-windows-msvc toolchain.
First time that I had this issue was in November when using gh runner logs: at the time I didn't give too much weight to the problem since on my Windows machine it compiled correctly and I assumed there was some problem with windows runner.
Since last Wednesday I've been having the same issue on my local machine too: I've tried toolchian from 1.80 to 1.84.1 (+ nightly) with the same result.
Linux and Macos work just fine.
I'm pretty sure I have seen some updates to vs build tools running in windows update but i don't recall which they are precisely.

Build command: cargo build

Let me know if there is any other information I can provide

Backtrace

error[E0463]: can't find crate for `hf_hub`
 --> src\modifier.rs:1:5
  |
1 | use hf_hub::api::sync::ApiError;
  |     ^^^^^^ can't find crate

error[E0463]: can't find crate for `hf_hub`
 --> src\preset_builder.rs:7:5
  |
7 | use hf_hub::api::sync::ApiError;
  |     ^^^^^^ can't find crate

error[E0463]: can't find crate for `hf_hub`
 --> src\util.rs:6:5
  |
6 | use hf_hub::api::sync::{ApiBuilder, ApiError};
  |     ^^^^^^ can't find crate

error[E0463]: can't find crate for `derive_builder`
 --> src\api.rs:9:5
  |
9 | use derive_builder::Builder;
  |     ^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `thiserror`
  --> src\api.rs:15:5
   |
15 | use thiserror::Error;
   |     ^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `derive_builder`
 --> src\preset.rs:1:5
  |
1 | use derive_builder::Builder;
  |     ^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `hf_hub`
 --> src\preset.rs:2:5
  |
2 | use hf_hub::api::sync::ApiError;
  |     ^^^^^^ can't find crate

error[E0432]: unresolved imports `crate::api::ConfigBuilder`, `crate::api::ConfigBuilderError`
 --> src\preset.rs:5:25
  |
5 |     api::{self, Config, ConfigBuilder, ConfigBuilderError},
  |                         ^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^ no `ConfigBuilderError` in `api`
  |                         |
  |                         no `ConfigBuilder` in `api`

error[E0432]: unresolved import `crate::api::ConfigBuilder`
 --> src\modifier.rs:4:11
  |
4 |     api::{ConfigBuilder, SampleMethod},
  |           ^^^^^^^^^^^^^ no `ConfigBuilder` in `api`

error[E0432]: unresolved import `crate::api::ConfigBuilder`
 --> src\preset_builder.rs:9:13
  |
9 | use crate::{api::ConfigBuilder, util::download_file_hf_hub};
  |             ^^^^^^^^^^^^^^^^^^ no `ConfigBuilder` in `api`

error: cannot find attribute `error` in this scope
  --> src\api.rs:38:7
   |
38 |     #[error("The underling stablediffusion.cpp function returned NULL")]
   |       ^^^^^

error: cannot find attribute `error` in this scope
  --> src\api.rs:40:7
   |
40 |     #[error("The underling stbi_write_image function returned 0 while saving image {0}/{1})")]
   |       ^^^^^

error: cannot find attribute `error` in this scope
  --> src\api.rs:42:7
   |
42 |     #[error("The underling upsclaer model returned a NULL image")]
   |       ^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:59:3
   |
59 | #[builder(setter(into, strip_option), build_fn(validate = "Self::validate"))]
   |   ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:64:7
   |
64 |     #[builder(default = "num_cpus::get_physical() as i32", setter(custom))]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:68:7
   |
68 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:72:7
   |
72 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:76:7
   |
76 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:80:7
   |
80 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:84:7
   |
84 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:88:7
   |
88 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:92:7
   |
92 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\api.rs:96:7
   |
96 |     #[builder(default = "Default::default()")]
   |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:100:7
    |
100 |     #[builder(default = "Default::default()")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:104:7
    |
104 |     #[builder(default = "Default::default()")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:108:7
    |
108 |     #[builder(default = "Default::default()")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:112:7
    |
112 |     #[builder(default = "false")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:116:7
    |
116 |     #[builder(default = "Default::default()")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:120:7
    |
120 |     #[builder(default = "0")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:124:7
    |
124 |     #[builder(default = "WeightType::SD_TYPE_COUNT")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:128:7
    |
128 |     #[builder(default = "Default::default()", setter(custom))]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:132:7
    |
132 |     #[builder(default = "Default::default()")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:136:7
    |
136 |     #[builder(default = "Default::default()")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:140:7
    |
140 |     #[builder(default = "PathBuf::from(\"./output.png\")")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:147:7
    |
147 |     #[builder(default = "\"\".into()")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:151:7
    |
151 |     #[builder(default = "7.0")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:155:7
    |
155 |     #[builder(default = "3.5")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:159:7
    |
159 |     #[builder(default = "0.75")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:163:7
    |
163 |     #[builder(default = "20.0")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:168:7
    |
168 |     #[builder(default = "0.9")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:172:7
    |
172 |     #[builder(default = "512")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:176:7
    |
176 |     #[builder(default = "512")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:180:7
    |
180 |     #[builder(default = "SampleMethod::EULER_A")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:184:7
    |
184 |     #[builder(default = "20")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:188:7
    |
188 |     #[builder(default = "RngFunction::CUDA_RNG")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:192:7
    |
192 |     #[builder(default = "42")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:196:7
    |
196 |     #[builder(default = "1")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:200:7
    |
200 |     #[builder(default = "Schedule::DEFAULT")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:205:7
    |
205 |     #[builder(default = "ClipSkip::Unspecified")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:209:7
    |
209 |     #[builder(default = "false")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:213:7
    |
213 |     #[builder(default = "false")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:217:7
    |
217 |     #[builder(default = "false")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:221:7
    |
221 |     #[builder(default = "false")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:225:7
    |
225 |     #[builder(default = "false")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:229:7
    |
229 |     #[builder(default = "None", private)]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:235:7
    |
235 |     #[builder(default = "false")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:240:7
    |
240 |     #[builder(default = "0.")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:244:7
    |
244 |     #[builder(default = "vec![7, 8, 9]")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:248:7
    |
248 |     #[builder(default = "0.01")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
   --> src\api.rs:252:7
    |
252 |     #[builder(default = "0.2")]
    |       ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\preset.rs:79:3
   |
79 | #[builder(
   |   ^^^^^^^

error: cannot find attribute `builder` in this scope
  --> src\preset.rs:88:7
   |
88 |     #[builder(private, default = "Vec::new()")]
   |       ^^^^^^^

error[E0412]: cannot find type `ConfigBuilder` in this scope
   --> src\api.rs:256:6
    |
256 | impl ConfigBuilder {
    |      ^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `ConfigBuilderError` in this scope
   --> src\api.rs:274:38
    |
274 |     fn validate(&self) -> Result<(), ConfigBuilderError> {
    |                                      ^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: you might be missing a type parameter
    |
256 | impl<ConfigBuilderError> ConfigBuilder {
    |     ++++++++++++++++++++

error[E0412]: cannot find type `ConfigBuilderError` in this scope
   --> src\api.rs:279:44
    |
279 |     fn validate_model(&self) -> Result<(), ConfigBuilderError> {
    |                                            ^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: you might be missing a type parameter
    |
256 | impl<ConfigBuilderError> ConfigBuilder {
    |     ++++++++++++++++++++

error[E0412]: cannot find type `ConfigBuilderError` in this scope
   --> src\api.rs:289:49
    |
289 |     fn validate_output_dir(&self) -> Result<(), ConfigBuilderError> {
    |                                                 ^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: you might be missing a type parameter
    |
256 | impl<ConfigBuilderError> ConfigBuilder {
    |     ++++++++++++++++++++

error[E0412]: cannot find type `PresetBuilder` in this scope
  --> src\preset.rs:92:6
   |
92 | impl PresetBuilder {
   |      ^^^^^^^^^^^^^ not found in this scope

error[E0433]: failed to resolve: use of undeclared type `ConfigBuilderError`
   --> src\api.rs:284:20
    |
284 |             .ok_or(ConfigBuilderError::UninitializedField(
    |                    ^^^^^^^^^^^^^^^^^^ use of undeclared type `ConfigBuilderError`

error[E0433]: failed to resolve: use of undeclared type `ConfigBuilderError`
   --> src\api.rs:295:17
    |
295 |             Err(ConfigBuilderError::ValidationError(
    |                 ^^^^^^^^^^^^^^^^^^ use of undeclared type `ConfigBuilderError`

Some errors have detailed explanations: E0412, E0432, E0433, E0463.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `diffusion-rs` (lib) due to 69 previous errors
PS C:\Users\newfl\diffusion-rs> 

@newfla newfla added the C-bug Category: bug label Feb 3, 2025
@newfla newfla changed the title [windows-msvc]: can't find crate for 'XYZ' (windows-msvc) can't find crate for 'XYZ' Feb 3, 2025
@newfla newfla changed the title (windows-msvc) can't find crate for 'XYZ' can't find crate for 'XYZ' (windows-msvc only) Feb 3, 2025
@jieyouxu

This comment has been minimized.

@jieyouxu jieyouxu added the S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. label Feb 3, 2025
@newfla
Copy link
Author

newfla commented Feb 3, 2025

@jieyouxu Did you clone the git submodules too? 🤔

@jieyouxu
Copy link
Member

jieyouxu commented Feb 3, 2025

I suspect this is a cargo resolver v2 feature unification thing, but I'm having a hard time pinning down which one is causing it (the main package's transitive deps vs the -sys package's [build-dependencies]). To me

error[E0463]: can't find crate for `hf_hub`

seems more likely to be a cargo dep resolution thing, so going to transfer this issue to cargo issue tracker (but please do kick it back to rust-lang/rust if it doesn't seem like a cargo concern).

Not sure if helpful for cargo triagers, but here's

`cargo +nightly tree -d -f '{p} {f}'`
PS X:\repos\diffusion-rs> cargo +nightly tree -d -f '{p} {f}'
libc v0.2.169
└── clang-sys v1.8.1 clang_10_0,clang_11_0,clang_3_5,clang_3_6,clang_3_7,clang_3_8,clang_3_9,clang_4_0,clang_5_0,clang_6_0,clang_7_0,clang_8_0,clang_9_0,libloading,runtime
    └── bindgen v0.71.1 default,logging,prettyplease,runtime
        [build-dependencies]
        └── diffusion-rs-sys v0.1.6 (X:\repos\diffusion-rs\sys)
            └── diffusion-rs v0.1.6 (X:\repos\diffusion-rs)

libc v0.2.169 default,std
├── console v0.15.10 ansi-parsing,unicode-width
│   └── indicatif v0.17.11 default,unicode-width
│       └── hf-hub v0.4.1 ureq
│           └── diffusion-rs v0.1.6 (X:\repos\diffusion-rs)
└── diffusion-rs v0.1.6 (X:\repos\diffusion-rs)

windows-sys v0.48.0 Win32,Win32_Foundation,Win32_Globalization,Win32_System,Win32_System_Com,Win32_UI,Win32_UI_Shell,default
└── dirs-sys v0.4.1
    └── dirs v5.0.1
        └── hf-hub v0.4.1 ureq (*)

windows-sys v0.59.0 Win32,Win32_Foundation,Win32_Storage,Win32_Storage_FileSystem,Win32_System,Win32_System_Console,Win32_UI,Win32_UI_Input,Win32_UI_Input_KeyboardAndMouse,default
└── console v0.15.10 ansi-parsing,unicode-width (*)

windows-targets v0.48.5
└── windows-sys v0.48.0 Win32,Win32_Foundation,Win32_Globalization,Win32_System,Win32_System_Com,Win32_UI,Win32_UI_Shell,default (*)

windows-targets v0.52.6
├── libloading v0.8.6
│   └── clang-sys v1.8.1 clang_10_0,clang_11_0,clang_3_5,clang_3_6,clang_3_7,clang_3_8,clang_3_9,clang_4_0,clang_5_0,clang_6_0,clang_7_0,clang_8_0,clang_9_0,libloading,runtime (*)
└── windows-sys v0.59.0 Win32,Win32_Foundation,Win32_Storage,Win32_Storage_FileSystem,Win32_System,Win32_System_Console,Win32_UI,Win32_UI_Input,Win32_UI_Input_KeyboardAndMouse,default (*)

windows_x86_64_msvc v0.48.5
└── windows-targets v0.48.5  (*)

windows_x86_64_msvc v0.52.6
└── windows-targets v0.52.6  (*)

@rustbot transfer cargo

@jieyouxu jieyouxu removed the S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. label Feb 3, 2025
@rustbot rustbot transferred this issue from rust-lang/rust Feb 3, 2025
@jieyouxu

This comment has been minimized.

@rustbot rustbot added the S-triage Status: This issue is waiting on initial triage. label Feb 3, 2025
@weihanglo weihanglo added the O-windows OS: Windows label Feb 3, 2025
@MilesConn
Copy link

I'm also having this issue. I've tried to debug as much as possible. All of a sudden cargo can't find crate. I've done

cargo clean
rm -rf ~/.cargo/registry
rm -rf ~/.cargo/git

and a few other things and I keep hitting can't find crate after reducing it to a minimal example. It'd build in the beginning and then I'd run some cargo cleans and it'd fail.

cargo --version      
cargo 1.84.0 (66221abde 2024-11-19)

I've confirmed I have the files in the cargo registry.

@weihanglo
Copy link
Member

It'd build in the beginning and then I'd run some cargo cleans and it'd fail.

Did you mean the first cargo build succeeded, and after running cargo clean subsequent cargo build started failing? Would you mind sharing a minimal reproducible example?

Were you also on Windows? Note that the original issue was described as only happening on Windows.

@MilesConn
Copy link

Did you mean the first cargo build succeeded, and after running cargo clean subsequent cargo build started failing? Would you mind sharing a minimal reproducible example?

Yes that's what happened. Reproducing in a minimal example might be difficult I think it's because there are two versions of the dependencies in my workspace so I'll try and make a reproducible example.

Were you also on Windows? Note that the original issue was described as only happening on Windows.

No I'm on NixOs but I saw can't find crate for 'XYZ' and thought it was potentially related. Sorry I don't mean to pollute the issue tracker

@weihanglo
Copy link
Member

@MilesConn for NixOS/Nixpkgs, see #12935 (comment). I am 98% sure the 'XYZ' crate you saw was proc-macro related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug O-windows OS: Windows S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

5 participants