{"record":{"id":"df32c61f474fd99f","repo":"abiosoft/colima","slug":"failed-to-parse-macos-version-q-w","errorCode":null,"errorMessage":"failed to parse macOS version %q: %w","messagePattern":"failed to parse macOS version %q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"util/macos.go","lineNumber":158,"sourceCode":"\treturn cmd.Run() == nil\n}\n\n// macOSProductVersion returns the host's macOS version.\nfunc macOSProductVersion() (*semver.Version, error) {\n\tcmd := exec.Command(\"sw_vers\", \"-productVersion\")\n\t// output is like \"12.3.1\\n\"\n\tb, err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to execute %v: %w\", cmd.Args, err)\n\t}\n\tverTrimmed := strings.TrimSpace(string(b))\n\t// macOS 12.4 returns just \"12.4\\n\"\n\tfor strings.Count(verTrimmed, \".\") < 2 {\n\t\tverTrimmed += \".0\"\n\t}\n\tverSem, err := semver.NewVersion(verTrimmed)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse macOS version %q: %w\", verTrimmed, err)\n\t}\n\treturn verSem, nil\n}\n","sourceCodeStart":140,"sourceCodeEnd":162,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/util/macos.go#L140-L162","documentation":"sw_vers ran and produced output, but after padding to at least three components (12.4 becomes 12.4.0) the trimmed string still is not valid semver for the vendored library. The output format is not a plain x.y.z version — pre-release/build suffixes, extra text, or empty output.","triggerScenarios":"sw_vers emitting non-semver strings: beta/build-seed suffixes, additional lines, or empty output after trimming (which pads to '.0.0' and fails to parse).","commonSituations":"Beta macOS seeds with unusual version strings; future sw_vers format changes breaking the parser.","solutions":["Run sw_vers -productVersion and inspect the exact output","Update colima — newer builds may handle the format","If maintaining a fork, strip pre-release/build suffixes or compare components manually instead of requiring strict semver","Accept the warning and the conservative feature fallback"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"ver, err := macOSVersion()\nif err != nil {\n    // unparseable output: treat as unknown, pick the conservative path\n    log.Printf(\"warning: %v; treating macOS version as unknown\", err)\n    return legacyPath()\n}","preventionTips":["Do not require strict semver from sw_vers output; parse major/minor components yourself for gates","Add tests for unusual sw_vers outputs (betas, two-component versions, empty) when touching version logic"],"tags":["macos","semver","version","parsing"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}