maturin "cargo metadata` exited with an error" in CI
maturin runs cargo metadata to discover your crate before building. If Cargo cannot parse Cargo.toml, resolve dependencies, or find the manifest, that command exits non-zero and maturin reports the cargo metadata failure verbatim.
What this error means
The maturin build stops with "Cargo metadata failed" or "cargo metadata exited with an error", followed by the cargo error (a manifest parse error, an unresolved dependency, or a missing Cargo.toml).
💥 maturin failed
Caused by: `cargo metadata` exited with an error: error: could not find `Cargo.toml`Common causes
Cargo.toml is missing or in the wrong directory
maturin runs cargo from the manifest path; if Cargo.toml is absent at the expected location, cargo metadata fails immediately.
A dependency or workspace cannot be resolved
A bad version requirement, an unreachable registry, or a broken workspace member makes cargo metadata exit with an error.
How to fix it
Point maturin at the correct manifest
- Confirm
Cargo.tomlexists at the project root or setmanifest-path. - Run
cargo metadatadirectly to see the real cargo error. - Fix the manifest or dependency cargo names.
cargo metadata --format-version 1
maturin build --manifest-path rust/Cargo.tomlAllow network access for dependency resolution
If the registry is unreachable on the runner, configure cargo to fetch deps or vendor them.
cargo fetch
maturin build --offlineHow to prevent it
- Run
cargo metadatain CI as a quick manifest sanity check. - Keep
Cargo.tomlat the path maturin expects. - Vendor or cache cargo dependencies for reliable resolution.