xai-org/grok-build · error

Failed to parse versions (current={}, target={})

Error message

Failed to parse versions (current={}, target={})

What it means

This is the fallback branch of the same check that produces the unsupported-channel error: both effective_current and install_target were attempted with semver::Version::parse and at least one failed. Because the versions themselves are unparseable, the updater cannot compute a channel-compatible plan and bails with the raw version strings.

Source

Thrown at crates/codegen/xai-grok-update/src/auto_update.rs:2846

                    // and skips leaders already at/after this version).
                    return Ok(Some(install_target));
                }
            }
            None => {
                // Distinguish parse failure from unsupported channel.
                let parse_ok = semver::Version::parse(&effective_current).is_ok()
                    && semver::Version::parse(&install_target).is_ok();
                if parse_ok {
                    anyhow::bail!(
                        "Unsupported release channel '{}' (current={}, target={}). \
                         Supported channels: stable, alpha, enterprise. \
                         Use --stable or --alpha to override, or set [cli] channel in config.toml.",
                        update_config.channel,
                        effective_current,
                        install_target
                    );
                } else {
                    anyhow::bail!(
                        "Failed to parse versions (current={}, target={})",
                        effective_current,
                        install_target
                    );
                }
            }
        }
    }

    let target_version = if force
        && !needs_update(
            &effective_current,
            &install_target,
            &update_config.channel,
            installer_allows_downgrade(installer),
        )
        .unwrap_or(true)
    {

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Check the installed version output (`grok --version`) and reinstall Grok if it reports a non-semver or placeholder version
  2. Correct the target version argument to valid semver (e.g. 1.2.3, optionally -alpha.1)
  3. Ensure no environment or config is injecting an empty/invalid current-version string
  4. If using a locally built binary, tag it with a proper semver version

Example fix

// before
my-updater --version v1.2   // 'v1.2' fails semver::Version::parse
// after
my-updater --version 1.2.0  // valid semver
# also ensure installed grok reports e.g. "1.2.0", not "" or "unknown"
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_semver(v: &str) -> bool { semver::Version::parse(v).is_ok() }
let current = get_installed_grok_version();
let target = requested_target;
if !is_valid_semver(&current) || !is_valid_semver(&target) {
    eprintln!("Refusing update: non-semver version (current={current:?}, target={target:?})");
    std::process::exit(2);
}

Type guard

fn as_semver(v: &str) -> Option<semver::Version> {
    semver::Version::parse(v).ok()
}

Try / catch

match run_update(target_opt).await {
    Err(e) if e.to_string().starts_with("Failed to parse versions") => {
        // Re-detect the installed version or reinstall before retrying
        reinstall_and_retry().await
    }
    other => other.map(|_| ())?,
}

Prevention

When it happens

Trigger: effective_current (installed Grok version string) or install_target is not valid semver — e.g. empty string, 'unknown', a version with non-numeric pre-release/build metadata, or output from `grok --version` in an unexpected format.

Common situations: Grok not installed so the detected version is empty/placeholder; a locally built binary reporting a non-semver version string (e.g. git describe output); corrupted install metadata; a target version typed with a typo (e.g. '1..2').

Understand the failure class

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/df9445d1bf76c611. Report an issue: GitHub.