Rust: use of undeclared crate or module (E0433)
error[E0433]: failed to resolve: use of undeclared crate or module `serde`
--> src/main.rs:1:5
1 | use serde::{Serialize, Deserialize};
| ^^^^^ use of undeclared crate or module `serde`
Immediate Remediation
bash
cargo add serde --features derive
Root Cause Analysis
The crate `serde` is not listed in Cargo.toml dependencies, so the compiler cannot find it when resolving the `use` statement. Adding it via cargo add updates Cargo.toml and fetches the crate.
Verification & Guardrails
- `cargo add` updates Cargo.toml automatically and uses the latest compatible version.
- If you need a specific version, use `cargo add serde@1.0` after checking crates.io.
- In a workspace, run `cargo add -p package_name serde` to target the correct crate.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.