Unresolved import error despite crate being present in cargo.toml?

⚓ Rust    📅 2026-02-26    👤 surdeus    👁️ 3      

surdeus

Hey all,

This is more of a why question since I can get it working following the instructions in the docs. I'm using the winresource crate: crates.io: Rust Package Registry to fill in file metadata for my Windows binary. Following their instructions works by adding the [build-dependencies] section to the cargo file.

I'm curious why you can't just add winresource as a normal dependency via cargo add and have it work the same? It's present in crates.io and I can successfully add it as a normal dependency. But when I try to use it, I get an unresolved import error in the build.rs file stating I need to add it with cargo add, which I've already done.

So what's different about this crate that requires the build-dependencies portion instead of just a normal dependency? Is build.rs unique that requires it's own dependencies apart from the project ones? In which case, why is it in crates.io if you don't add it with cargo add?

3 posts - 2 participants

Read full topic

🏷️ Rust_feed