gitbutlerapp/gitbutler · error

Invalid version format

Error message

Invalid version format: {version}. Version must contain only alphanumeric characters, dots, hyphens, and plus signs.

What it means

validate enforces semver-compatible characters only: alphanumeric, '.', '-', '+'. A version containing spaces, slashes, underscores, parentheses, etc. bails with this message naming the offending input.

Solutions

  1. Pass only the tag/version token, e.g. `0.14.2` or `v0.14.2` — strip any surrounding prose or refs prefix.
  2. Trim whitespace in scripts: `VERSION=$(echo "$VERSION" | tr -d '[:space:]')`.
  3. If deriving from `git describe`, drop decorators (`git describe --tags --abbrev=0`).
  4. Use `nightly` when you want the rolling channel rather than a descriptive string.

Example fix

// before
but-installer "0.14.2 (beta)"
// after
but-installer 0.14.2-beta
Defensive patterns

Strategy: validation

Validate before calling

fn is_semverish(v: &str) -> bool {
    !v.is_empty() && v.chars().all(|c| c.is_alphanumeric() || matches!(c, '.' | '-' | '+'))
}
assert!(is_semverish(version), "illegal characters in version: {version}");

Try / catch

match InstallerConfig::new() {
    Err(e) if e.to_string().contains("only alphanumeric characters") => {
        eprintln!("{e}\nPass a plain tag like 0.14.2, not a ref or description");
        std::process::exit(2);
    }
    Err(e) => return Err(e),
    Ok(cfg) => run(cfg),
}

Prevention

When it happens

Trigger: Passing values like `0.14.2 (beta)`, `v0.14.2/fix`, `latest stable`, a full tag reference `refs/tags/0.14.2`, or a URL fragment as the version argument or GITBUTLER_VERSION.

Common situations: Scripts passing a git ref or release title instead of the tag name; copy-pasting from a browser with trailing whitespace or annotation text; using `v` prefix is fine, but adding labels like `stable` is not.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/e1c8ef7a5b25bf4f. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-installer/src/config.rs:60

    /// Validate a version string format
    fn validate(version: &str) -> Result<()> {
        // Reject empty strings
        if version.is_empty() {
            bail!("Invalid version: empty string. Usage: but-installer [version|nightly]");
        }

        // Reject if it looks like a flag
        if version.starts_with('-') {
            bail!("Invalid version: {version}. Usage: but-installer [version|nightly]");
        }

        // Only allow semver-compatible characters
        if !version
            .chars()
            .all(|c| c.is_alphanumeric() || c == '.' || c == '-' || c == '+')
        {
            bail!(
                "Invalid version format: {version}. Version must contain only alphanumeric characters, dots, hyphens, and plus signs."
            );
        }

        // Must contain at least one alphanumeric character
        if !version.chars().any(|c| c.is_alphanumeric()) {
            bail!(
                "Invalid version format: {version}. Version must contain at least one alphanumeric character."
            );
        }

        Ok(())
    }

    /// Get the version string as a &str
    pub fn as_str(&self) -> &str {
        &self.0
    }

View on GitHub (pinned to 58e5313667)