ipfs/kubo · error

could not parse our own version %q: %w

Error message

could not parse our own version %q: %w

What it means

DetectNewKuboVersion parses version.CurrentVersionNumber (the numeric Kubo version like '0.30.0') into a semver to compare against versions seen in the swarm. If that string cannot be parsed as a version, the error wraps the parse failure with the offending value. This indicates the compiled-in version string is malformed — a build/packaging problem, not a runtime issue.

Source

Thrown at core/commands/version.go:203

		if err != nil {
			return err
		}

		if err := cmds.EmitOnce(res, output); err != nil {
			return err
		}
		return nil
	},
}

// DetectNewKuboVersion observers kubo version reported by other peers via
// libp2p identify protocol and notifies when threshold fraction of seen swarm
// is running updated Kubo. It is used by RPC and CLI at 'ipfs version check'
// and also periodically when 'ipfs daemon' is running.
func DetectNewKuboVersion(nd *core.IpfsNode, minPercent int64) (VersionCheckOutput, error) {
	ourVersion, err := versioncmp.NewVersion(version.CurrentVersionNumber)
	if err != nil {
		return VersionCheckOutput{}, fmt.Errorf("could not parse our own version %q: %w",
			version.CurrentVersionNumber, err)
	}
	// MAJOR.MINOR.PATCH without any suffix
	ourVersion = ourVersion.Core()

	greatestVersionSeen := ourVersion
	totalPeersSampled := 1 // Us (and to avoid division-by-zero edge case)
	withGreaterVersion := 0

	recordPeerVersion := func(agentVersion string) {
		// We process the version as is it assembled in GetUserAgentVersion
		segments := strings.Split(agentVersion, "/")
		if len(segments) < 2 {
			return
		}
		if segments[0] != "kubo" {
			return
		}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Rebuild using make build so the Makefile injects the correct version ldflags
  2. Ensure your build passes -ldflags "-X github.com/ipfs/kubo/version.CurrentVersionNumber=<semver>"
  3. Check that the resulting 'ipfs version' prints a sane MAJOR.MINOR.PATCH number
  4. Use an official release binary instead of a hand-built one

Example fix

// before (custom build script)
go build -o ipfs ./cmd/ipfs
// after
make build  # or: go build -ldflags "-X github.com/ipfs/kubo/version.CurrentVersionNumber=0.30.0" -o ipfs ./cmd/ipfs
Defensive patterns

Strategy: validation

Validate before calling

v := version.CurrentVersionNumber
if v == "" {
    return errors.New("version.CurrentVersionNumber is empty; build via make build")
}
if _, err := versioncmp.NewVersion(v); err != nil {
    return fmt.Errorf("bad embedded version %q: %w", v, err)
}

Try / catch

out, err := DetectNewKuboVersion(nd, 25)
if err != nil && strings.Contains(err.Error(), "could not parse our own version") {
    // degrade: skip swarm version check, log a warning
    log.Warnf("swarm version check skipped: %v", err)
    return VersionCheckOutput{}, nil
}
return out, err

Prevention

When it happens

Trigger: Calling 'ipfs version check' or running 'ipfs daemon' with periodic swarm version check when version.CurrentVersionNumber (set via ldflags at build time) is empty or not in a parseable MAJOR.MINOR.PATCH form.

Common situations: Building from a git checkout without the Makefile's ldflags injection (CurrentCommit/version left blank); custom build scripts that drop the -ldflags '-X github.com/ipfs/kubo/version.CurrentVersionNumber=...' flags; typos in a custom version string.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/fe1ca348f82c2ab9. Report an issue: GitHub.