Cargo "failed to parse manifest" - Fix Cargo.toml Errors in CI
Cargo could not parse your Cargo.toml. The TOML is malformed, a key is misspelled or in the wrong table, or a dependency entry has invalid syntax - Cargo stops before resolving anything.
What this error means
cargo fails immediately with failed to parse manifest at <path>/Cargo.toml and a Caused by: line pointing at the offending line or key. It is deterministic and reproduces locally with the same manifest.
error: failed to parse manifest at `/home/runner/work/app/Cargo.toml`
Caused by:
invalid type: string "1.0", expected a table or string for key `dependencies.serde`
TOML parse error at line 9, column 1
|
9 | [dependencies]
| ^Common causes
Malformed TOML or wrong table
A missing quote, a duplicate key, or a value placed in the wrong table (e.g. a dependency under [package]) makes the TOML invalid or the key meaningless.
A dependency entry with bad syntax
A dependency must be a version string or an inline table. serde = { 1.0 } or a stray comma produces a parse error naming the dependency key.
How to fix it
Fix the line the error names
Cargo prints the file, line, and column. Correct the syntax there - version strings or inline tables for dependencies.
[dependencies]
serde = "1.0"
serde_json = { version = "1.0", features = ["std"] }Validate the manifest locally
Run a cargo command that only parses the manifest to catch the error before pushing.
cargo metadata --no-deps --format-version 1 >/dev/null
# or simply
cargo verify-projectHow to prevent it
- Run
cargo verify-projectorcargo metadatain a pre-commit hook. - Use a TOML-aware editor or linter to catch malformed tables early.
- Copy dependency syntax from crates.io rather than hand-writing inline tables.