gitbutlerapp/gitbutler · error · anyhow::Error

Invalid version '{version_str}': {e} Valid targets: night

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

`but update <target>` accepts exactly three shapes: the literal 'nightly', the literal 'release', or a concrete version string that VersionRequest::from_string can parse. Anything else fails validation, and the error message lists the valid forms.

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 caf1f223d3)

Solutions

  1. Use a channel: `but update nightly` or `but update release`
  2. Use a full concrete version as printed by releases, e.g. `but update 0.18.7`
  3. Omit the argument to auto-detect from the current channel (nightly upgrades to nightly; release and dev go to release)

Example fix

# before
but update latest   # invalid target
# after
but update release
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_target(t: &str) -> bool {
    t == "nightly"
        || t == "release"
        || VersionRequest::from_string(Some(t.to_string())).is_ok()
}

Prevention

When it happens

Trigger: `but update latest`, `but update stable`, `but update v0.18.7`, or a partial/malformed version string: all fail VersionRequest::from_string validation.

Common situations: Guessing the channel vocabulary ('stable' instead of 'release'), adding a 'v' prefix, or truncating the version number.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/2d255127405aff1b. Report an issue: GitHub.