abiosoft/colima · warning

failed to parse macOS version %q: %w

Error message

failed to parse macOS version %q: %w

What it means

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.

Source

Thrown at util/macos.go:158

	return cmd.Run() == nil
}

// macOSProductVersion returns the host's macOS version.
func macOSProductVersion() (*semver.Version, error) {
	cmd := exec.Command("sw_vers", "-productVersion")
	// output is like "12.3.1\n"
	b, err := cmd.Output()
	if err != nil {
		return nil, fmt.Errorf("failed to execute %v: %w", cmd.Args, err)
	}
	verTrimmed := strings.TrimSpace(string(b))
	// macOS 12.4 returns just "12.4\n"
	for strings.Count(verTrimmed, ".") < 2 {
		verTrimmed += ".0"
	}
	verSem, err := semver.NewVersion(verTrimmed)
	if err != nil {
		return nil, fmt.Errorf("failed to parse macOS version %q: %w", verTrimmed, err)
	}
	return verSem, nil
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Run sw_vers -productVersion and inspect the exact output
  2. Update colima — newer builds may handle the format
  3. If maintaining a fork, strip pre-release/build suffixes or compare components manually instead of requiring strict semver
  4. Accept the warning and the conservative feature fallback
Defensive patterns

Strategy: fallback

Try / catch

ver, err := macOSVersion()
if err != nil {
    // unparseable output: treat as unknown, pick the conservative path
    log.Printf("warning: %v; treating macOS version as unknown", err)
    return legacyPath()
}

Prevention

When it happens

Trigger: 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).

Common situations: Beta macOS seeds with unusual version strings; future sw_vers format changes breaking the parser.

Understand the failure class

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/df32c61f474fd99f. Report an issue: GitHub.