{"record":{"id":"314308e432bae77b","repo":"gitbutlerapp/gitbutler","slug":"installation-failed-but-your-previous-installation-314308","errorCode":null,"errorMessage":"Installation failed but your previous installation was restored","messagePattern":"Installation failed but your previous installation was restored","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-installer/src/install_macos.rs","lineNumber":271,"sourceCode":"        } else {\n            bail!(\"Failed to create symlink: {e}. No backup available to restore.\");\n        }\n    }\n\n    if !validate_installed_binary(&but_symlink) {\n        // Try to restore backup\n        warn(\"Final installation verification failed - attempting to restore backup\");\n        if install_app_backup.exists() {\n            fs::remove_dir_all(&install_app)?;\n            fs::rename(&install_app_backup, &install_app)?;\n\n            let restored_target = install_app.join(\"Contents/MacOS/gitbutler-tauri\");\n            let _ = fs::remove_file(&but_symlink);\n            unix_fs::symlink(&restored_target, &but_symlink)?;\n\n            if validate_installed_binary(&but_symlink) {\n                success(\"Backup was restored successfully\");\n                bail!(\"Installation failed but your previous installation was restored\");\n            } else {\n                bail!(\n                    \"Installation failed and backup restoration also failed - 'but' command may not work\"\n                );\n            }\n        } else {\n            bail!(\"Installation failed and no backup available to restore\");\n        }\n    }\n\n    success(&format!(\n        \"{} installed successfully\",\n        app_basename.to_string_lossy()\n    ));\n    // Remove backup on success\n    let _ = fs::remove_dir_all(&install_app_backup);\n\n    success(\"GitButler CLI (but) installed successfully\");","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/install_macos.rs#L253-L289","documentation":"The macOS `but` CLI installer failed to install the newly downloaded .app bundle, but a backup of the previous installation existed, was restored, and passed binary validation. The installer reports the good news (previous install restored) and then aborts with this error so the caller knows the update did not succeed even though `but` remains usable.","triggerScenarios":"install_app (via download_and_install_app) fails to move/replace the downloaded app into place, a backup directory exists and is copied back over the target, unix_fs::symlink re-points the `but` symlink at the restored binary, and validate_installed_binary(&but_symlink) succeeds — then bail! is called.","commonSituations":"Corrupted or partially downloaded update archive, target app bundle in use or write-protected so the install step fails, disk full during copy, upgrade attempts over an existing healthy installation where the backup path is populated.","solutions":["Nothing is broken: the previous installation was restored and works — investigate why the update failed (check network, disk space, permissions) and retry the update","Check permissions on the install target directory (often /Applications or ~/Applications) and ensure the app bundle is not running/locked during update","Re-run the installer; if it repeatedly fails, download the release archive manually and replace the app bundle by hand"],"exampleFix":"// before: treating restore as a hard failure\nbail!(\"Installation failed but your previous installation was restored\");\n// after: caller-side handling\nmatch install_result {\n    Err(e) if e.to_string().contains(\"previous installation was restored\") => {\n        warn!(\"Update failed; still running previous version. Will retry later.\");\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","handlingStrategy":"fallback","validationCode":"fn previous_install_ok(but_symlink: &std::path::Path) -> bool {\n    but_symlink.exists() && std::fs::read_link(but_symlink).map(|t| t.exists()).unwrap_or(false)\n}","typeGuard":"fn is_restored_error(e: &anyhow::Error) -> bool {\n    e.to_string().contains(\"previous installation was restored\")\n}","tryCatchPattern":"match download_and_install_app(...).await {\n    Err(e) if is_restored_error(&e) => warn!(\"update failed, previous version still active\"),\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Close the running app before updating so target paths are not locked","Check free disk space before starting an update","Verify download integrity (checksum) before installing","Run the installer with write permission to the target Applications directory"],"tags":["macos","installer","update-failed","backup-restored"],"backgroundTag":"app-install-failed-previous-restored","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}