gitbutlerapp/gitbutler · error

Invalid version ' ': Valid targets: nightly Install latest…

Error message

Invalid version '{version_str}': {e}

Valid targets:
  nightly          Install latest nightly build
  release          Install latest stable release
  <version>        Install specific version (e.g., 0.18.7)

What it means

The `but update` command validates a user-supplied version argument via `VersionRequest::from_string`. When the string is neither `nightly`, `release`, nor a parseable version, the underlying parse error is wrapped with this message listing the valid targets.

Solutions

  1. Use one of the exact valid targets: `but update nightly`, `but update release`, or `but update 0.18.7` (bare semver, no `v` prefix).
  2. Check the currently installed version with `but --version` and pick a matching format for the target version.
  3. Run `but update` with no argument to auto-detect from the current channel instead of specifying a version.

Example fix

// before
but update stable

// after
but update release   # or: but update 0.18.7
Defensive patterns

Strategy: validation

Validate before calling

// shell, before invoking
VERSION="0.18.7"
echo "$VERSION" | grep -Eq '^(nightly|release|[0-9]+\.[0-9]+\.[0-9]+)$' || { echo "invalid target: $VERSION"; exit 1; }

Try / catch

match update(target) {
    Err(e) if e.to_string().contains("Invalid version") =>
        eprintln!("Use nightly, release, or an x.y.z version"),
    other => other?,
}

Prevention

When it happens

Trigger: Running `but update <version>` with a malformed version string — wrong separator (`0.18` is fine but `v0.18.7` with a `v` prefix or `0.18.x` may fail), misspelled keyword (`stable` instead of `release`), or an empty/garbage token.

Common situations: Typing `but update stable` or `but update latest` (unsupported keywords); copy-pasting a tag like `v0.18.7`; scripting with an unescaped variable that resolves to an unexpected string.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at crates/but/src/command/update.rs:154

    // because the installer writes directly to stdout/stderr
    if out.for_json().is_some() {
        anyhow::bail!(
            "JSON output is not supported for 'but update install'.\n\n\
             The installation process requires interactive output.\n\
             For automated installations, use the standalone installer:\n\
             https://docs.gitbutler.com/installation"
        );
    }

    // Parse target to determine what to install
    let version_request = match target.as_deref() {
        Some("nightly") => VersionRequest::Nightly,
        Some("release") => VersionRequest::Release,
        Some(version_str) => {
            // Specific version - validate and create
            // Wrap validation errors with CLI-specific context
            VersionRequest::from_string(Some(version_str.to_string())).map_err(|e| {
                anyhow::anyhow!(
                    "Invalid version '{version_str}': {e}\n\nValid targets:\n  nightly          Install latest nightly build\n  release          Install latest stable release\n  <version>        Install specific version (e.g., 0.18.7)"
                )
            })?
        }
        None => {
            // Auto-detect from current channel
            let current_channel = but_path::AppChannel::new();
            match current_channel {
                but_path::AppChannel::Nightly => VersionRequest::Nightly,
                but_path::AppChannel::Release => VersionRequest::Release,
                but_path::AppChannel::Dev => VersionRequest::Release, // Dev installs release
            }
        }
    };

    // Call installer directly (handles all user-facing output)
    // Don't print usage info since user is already using the CLI
    but_installer::run_installation_with_version(version_request, false)?;

View on GitHub (pinned to 58e5313667)