{"record":{"id":"748a7f328b5d223a","repo":"charmbracelet/gum","slug":"could-not-parse-version-s-w","errorCode":null,"errorMessage":"could not parse version %s: %w","messagePattern":"could not parse version (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"version/command.go","lineNumber":20,"sourceCode":"package version\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/Masterminds/semver/v3\"\n\t\"github.com/alecthomas/kong\"\n)\n\n// Run check that a given version matches a semantic version constraint.\nfunc (o Options) Run(ctx *kong.Context) error {\n\tc, err := semver.NewConstraint(o.Constraint)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not parse range %s: %w\", o.Constraint, err)\n\t}\n\tcurrent := ctx.Model.Vars()[\"versionNumber\"]\n\tv, err := semver.NewVersion(current)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not parse version %s: %w\", current, err)\n\t}\n\tif !c.Check(v) {\n\t\treturn fmt.Errorf(\"gum version %q is not within given range %q\", current, o.Constraint)\n\t}\n\treturn nil\n}\n","sourceCodeStart":2,"sourceCodeEnd":27,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/version/command.go#L2-L27","documentation":"The gum binary's own version string, taken from the kong context var 'versionNumber', could not be parsed as a semantic version. The constraint parsed fine, but the current version value is malformed. The parse error is wrapped with %w.","triggerScenarios":"`ctx.Model.Vars()[\"versionNumber\"]` contains a value semver.NewVersion cannot parse — typically only when running an unreleased/dev build whose version var is empty or non-semantic, since normal builds inject a valid version.","commonSituations":"Building gum from source without version ldflags so versionNumber is empty or 'dev', altered binary metadata, or running a stripped/modified build.","solutions":["Install an official gum release where versionNumber is a valid semver","Rebuild with proper ldflags, e.g. -X main.version=v0.14.0","Check `gum --version` output to see what version string is being used","If testing dev builds, pass a semver-compatible version at build time"],"exampleFix":"// before\ngo build -o gum ./...        # versionNumber empty → parse fails\n// after\ngo build -ldflags \"-X main.version=v0.14.1\" -o gum .","handlingStrategy":"fallback","validationCode":"ver=$(gum --version 2>/dev/null | grep -oE '[0-9]+\\.[0-9]+\\.[0-9]+')\n[ -n \"$ver\" ] || echo 'warning: gum version not semver-parseable (dev build?)'","typeGuard":null,"tryCatchPattern":"if ! gum version --check \">= 0.14.0\" 2>/dev/null; then\n  case \"$?\" in 0) ;; *) echo 'version check skipped (dev build)' ;; esac\nfi","preventionTips":["Build gum with version ldflags set to a semver tag","Prefer official release binaries","Check `gum --version` before relying on version checks"],"tags":["semver","build","versioning"],"backgroundTag":"invalid-version-string","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}