ipfs/kubo · error
parsing current version %q: %w
Error message
parsing current version %q: %w
What it means
isNewerVersion in core/commands/update.go compares two version strings using go-version. When the CURRENT version string (e.g. the running ipfs binary's version) cannot be parsed as a valid semver-ish version, the function wraps goversion.NewVersion's error with `parsing current version %q: %w`. It signals that the version-comparison input is malformed, not that the update check itself failed.
Source
Thrown at core/commands/update.go:841
// trimVPrefix removes a leading "v" from a version string.
func trimVPrefix(s string) string {
return strings.TrimPrefix(s, "v")
}
// normalizeVersion ensures a version string has a "v" prefix (for GitHub tags).
func normalizeVersion(s string) string {
s = strings.TrimSpace(s)
if !strings.HasPrefix(s, "v") {
return "v" + s
}
return s
}
// isNewerVersion returns true if target is newer than current.
func isNewerVersion(current, target string) (bool, error) {
cv, err := goversion.NewVersion(current)
if err != nil {
return false, fmt.Errorf("parsing current version %q: %w", current, err)
}
tv, err := goversion.NewVersion(target)
if err != nil {
return false, fmt.Errorf("parsing target version %q: %w", target, err)
}
return tv.GreaterThan(cv), nil
}
View on GitHub (pinned to 329838acdf)
Solutions
- Print and fix the source of the current version: run `ipfs version --number` and correct whatever produces the malformed string (build ldflags, version file).
- If testing, pass a valid semver string like '0.30.0' to isNewerVersion instead of a placeholder.
- Strip extraneous build metadata/leading text before calling: trim to the core `X.Y.Z` segment or use goversion regex to validate.
- Rebuild/install an official binary with `make build` or the official installer so CurrentVersion is a proper semver.
Example fix
// before
newer, err := isNewerVersion(getVersion(), target) // getVersion() returns "dev-dirty"
// after
cur := getVersion()
if _, perr := goversion.NewVersion(cur); perr != nil {
cur = "0.0.0" // fall back to a parseable baseline for dev builds
}
newer, err := isNewerVersion(cur, target) Defensive patterns
Strategy: validation
Validate before calling
if _, err := goversion.NewVersion(currentVersion); err != nil {
return fmt.Errorf("current version %q is not a valid version: %w", currentVersion, err)
} Type guard
func isParseableVersion(v string) bool {
_, err := goversion.NewVersion(v)
return err == nil
} Try / catch
newer, err := isNewerVersion(current, target)
if err != nil {
var verr *goversion.Error
if errors.As(err, &verr) { /* malformed input, not a network failure */ }
return fmt.Errorf("update check aborted: %w", err)
} Prevention
- Always build with the standard ldflags so the version string is a clean semver
- Validate any version string with goversion.NewVersion before comparing
- Trim 'v' prefixes and build metadata before parsing
- Never pass user text or branch names directly as a version
When it happens
Trigger: Calling `ipfs update check` (or any command path that reaches isNewerVersion via the anonymous caller) when the current version string is empty, a dev build string like 'ipfs version 0.0.0-fsdf...', contains non-numeric junk ('unknown', 'canary+dirty'), or a malformed semver ('1.2' is fine but 'abc' is not).
Common situations: Running a locally built binary from a dirty git checkout whose version string was overridden, a truncated/corrupted version file in IPFS_PATH, tests passing placeholder strings, or a fork that injects a non-semver build metadata suffix.
Related errors
- parsing target version %q: %w
- supernode routing was never fully implemented and has been r
- unrecognized routing option: %s
- invalid configuration profile: %s
- command disabled: %v
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/033e2d8da9f6321f.
Report an issue: GitHub.