/errors/semver/unexpected-end-of-input-while-parsing-minor-version-number
Cargo: unexpected end of input while parsing minor version number
- tool
- SemVer
- exit code
- 101
- versions
- Cargo 1.x (semver crate 1.x)
- os
- any
unexpected end of input while parsing minor version number means Cargo read the version of your package in Cargo.toml and it is not a full Semantic Version: [package] version must be exactly MAJOR.MINOR.PATCH, such as 1.0.0. version = "1.0" stops after the minor number; version = "1" stops after the major one. Write all three numbers.
Reproduce it
mkdir -p src && echo 'fn main() {}' > src/main.rs
for v in 1.0 1; do
printf '[package]\nname = "demo"\nversion = "%s"\nedition = "2021"\n' "$v" > Cargo.toml
cargo metadata --format-version 1 --no-deps --offline >/dev/null
done
printf '[package]\nname = "demo"\nversion = "1.0.0"\nedition = "2021"\n' > Cargo.toml
cargo metadata --format-version 1 --no-deps --offline >/dev/null && echo "1.0.0 parses"
printf '[package]\nname = "demo"\nversion = "1.0"\nedition = "2021"\n' > Cargo.toml
cargo metadata --format-version 1 --no-deps --offline >/dev/nullOutput · exit 101
error: unexpected end of input while parsing minor version number --> Cargo.toml:3:11 | 3 | version = "1.0" | ^^^^^ error: unexpected end of input while parsing major version number --> Cargo.toml:3:11 | 3 | version = "1" | ^^^ 1.0.0 parses error: unexpected end of input while parsing minor version number --> Cargo.toml:3:11 | 3 | version = "1.0" | ^^^^^
The message names the part where the input ended: with "1" the parser expected a . after the major number, so the wording is while parsing major version number. Both have the same fix.
Package version vs dependency requirement
| Where | Example | Short forms allowed? |
|---|---|---|
| [package] version | version = "1.0.0" | No: must be MAJOR.MINOR.PATCH |
| [dependencies] | serde = "1.0" | Yes: a requirement, means ^1.0 (>=1.0.0, <2.0.0) |
| rust-version | rust-version = "1.80" | Yes: a bare version like 1.80, no ranges or wildcards |
A broken dependency requirement fails differently, with failed to parse the version requirement and the dependency name, followed by the detail (for example expected comma after patch version number, found '.' for "1.0.x.1").