gitbutlerapp/gitbutler · error

Installation failed and no backup available to restore

Error message

Installation failed and no backup available to restore

What it means

On Linux, when installing the new binary fails and no backup of the previous binary was ever created (typically a first-time install rather than an upgrade), there is nothing to roll back to, so the installer bails with this message. The system simply has no working new installation at the target path.

Solutions

  1. Re-run the installer with elevated permissions if the target dir requires them (sudo), or choose a user-writable install location.
  2. Create/verify the install directory exists and is writable before installing (mkdir -p, check ownership).
  3. Free disk space / check quota, then retry the install.
  4. Download the artifact manually and place it at the expected path with executable permissions.

Example fix

// before
sudo but install   # fails: cannot write /usr/local/bin/but
// after
mkdir -p ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
but install   # installs to user-writable location
chmod +x ~/.local/bin/but
Defensive patterns

Strategy: validation

Validate before calling

let dir = install_bin_path.parent().unwrap();
std::fs::create_dir_all(dir)?;
let probe = dir.join(".write-probe");
std::fs::write(&probe, b"").context("install dir not writable")?;
std::fs::remove_file(&probe)?;

Try / catch

match install_app(&config) {
    Err(e) if e.to_string().contains("no backup available") => {
        eprintln!("first install failed: {e:#}. Fix permissions/space and retry.");
        std::process::exit(1);
    }
    r => r?,
}

Prevention

When it happens

Trigger: First-time install where the new binary move/write fails (permissions, disk full, target dir missing) — `but_backup` is None so the restore branch cannot run.

Common situations: Installing into /usr/local/bin without sudo; target directory doesn't exist and creation failed; disk quota exceeded; antivirus/EDR removing the freshly written binary.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-installer/src/install_linux.rs:124

    fs::set_permissions(&install_bin_path, perms)?;

    if !validate_installed_binary(&install_bin_path) {
        warn("Final installation verification failed");

        if let Some(but_backup) = but_backup {
            warn("Attempting to restore backup");
            fs::rename(&but_backup, &install_bin_path)?;

            if validate_installed_binary(&install_bin_path) {
                info("Backup restored successfully, exiting ...");
                bail!("Installation failed but your previous installation was restored");
            } else {
                bail!(
                    "Installation failed and backup restoration also failed - 'but' command may not work"
                );
            }
        } else {
            bail!("Installation failed and no backup available to restore");
        }
    } else if let Some(but_backup) = but_backup {
        info(&format!(
            "Removing backup at {}",
            but_backup.to_string_lossy()
        ));
        fs::remove_file(&but_backup)?;
    }

    Ok(())
}

View on GitHub (pinned to 58e5313667)