Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Unresolved import for a crate on crates.io
I have published a crate (serial_traits), and I want to use it for my other projects.
However, if I do use serial_traits
, I get red underlines with this hover popup:
unresolved import `serial_traits`
if you wanted to use a crate named `serial_traits`, use `cargo add serial_traits` to add it to your `Cargo.toml`
The problem is that this error message is contradicting Cargo.toml
:
[package]
name = "common"
version = "0.1.0"
edition = "2024"
[dependencies]
glam = "0.30.4"
serial_traits = "1.1.0"
This is a workplace, and the common
crate with its dependencies was initialized with the following commands:
cargo new common --lib
cargo add glam
cargo add serial_traits
An extra thing I have done is that I added net_structs.rs
(where I am trying to use serial_traits
in), which I have let VSCode know the existence of by putting pub mod net_structs;
in lib.rs
.
I saw that others have had the same or similar problem and solved it (like this one) and I tried their solutions.
Their suggestions did not work.
Something I have noticed is that occasionally, after changing edition
(trying other editions), rust-analyzer
would temporarily accept that serial_traits
exists.
And yet, cargo test
and cargo build
would still give this output:
error[E0432]: unresolved import `serial_traits`
>cargo test
Compiling glam v0.30.4
Compiling serial_traits v1.1.0
Compiling common v0.1.0 (C:\Users\[me]\Projects\Git Repos\wasm_2dtestmpgame\common)
error[E0432]: unresolved import `serial_traits`
--> common\src\net_structs.rs:2:5
|
2 | use serial_traits::Serializable;
| ^^^^^^^^^^^^^ use of unresolved module or unlinked crate `serial_traits`
|
= help: if you wanted to use a crate named `serial_traits`, use `cargo add serial_traits` to add it to your `Cargo.toml`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `common` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
The cargo build
and cargo test
commands were ran after cargo clean
ing, and it shows that serial_traits
successfully compiles.
Other things I have tried out, repeatedly, in arbitrary orders:
VSCode
Command Prompt
cargo clean
serial_traits
rustup update
Is there something I am missing? Maybe during the publishing process?
I have no idea what other options even exist, and I don't want to clone copies of my crate into each project I want to use it in.
4 posts - 3 participants
🏷️ rust_feed