Skip to content

/errors/semver/unexpected-end-of-input-while-parsing-minor-version-number

Cargo: unexpected end of input while parsing minor version number

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
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

bash
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/null

Output · 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

WhereExampleShort forms allowed?
[package] versionversion = "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-versionrust-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").

Sources