{"record":{"id":"2859bcd5bfa9619e","repo":"gitbutlerapp/gitbutler","slug":"failed-to-rename-to-application-may-fail-t","errorCode":null,"errorMessage":"Failed to rename {} to {} - application may fail to startup: {err}","messagePattern":"Failed to rename (.+?) to (.+?) - application may fail to startup: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-tauri/src/projects.rs","lineNumber":143,"sourceCode":"                         this app was used to open the project. '{}' is incompatible\",\n                        db_path.display()\n                    )\n                })\n                .context(but_error::Code::ProjectDatabaseIncompatible);\n        }\n        let db_filename = db_path.file_name().unwrap();\n        let max_attempts = 255;\n        for round in 1..max_attempts {\n            let backup_path = data_dir.join(format!(\n                \"{db_name}.maybe-broken-{round:02}\",\n                db_name = Path::new(db_filename).display()\n            ));\n            if backup_path.is_file() {\n                continue;\n            }\n\n            if let Err(err) = std::fs::rename(&db_path, &backup_path) {\n                bail!(\n                    \"Failed to rename {} to {} - application may fail to startup: {err}\",\n                    db_path.display(),\n                    backup_path.display()\n                );\n            }\n\n            return Ok(Some(format!(\n                \"Could not open db file at '{}'.\\nIt was moved to {} for recovery. \\n\\nError was: {err}\",\n                db_path.display(),\n                backup_path.display()\n            )));\n        }\n        bail!(\n            \"Database file at '{db_path} has {max_attempts} corrupted copies - giving up, application probably won't work\",\n            db_path = db_path.display()\n        );\n    }\n    Ok(None)","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/gitbutler-tauri/src/projects.rs#L125-L161","documentation":"Thrown during the app's startup database quarantine (gitbutler-tauri) when opening the project db failed and moving the broken file aside also fails. The recovery flow renames the db to <db_name>.maybe-broken-NN so a fresh one can be created; if std::fs::rename itself errors, the quarantine cannot proceed and startup is at risk, as the message warns.","triggerScenarios":"The db open failed, and the quarantine rename of db_path to data_dir/<db_name>.maybe-broken-NN returns Err - typical on Windows when another process (antivirus, backup agent, second app instance) holds the file open, or when the volume is full or read-only.","commonSituations":"Antivirus or backup software locking the db during startup; two app instances launched simultaneously; data directory made read-only by permissions changes or corporate policy; the data dir on a network/removable mount that disappeared.","solutions":["Close every GitButler process, temporarily exclude the data dir from AV/backup scanning, and relaunch so the quarantine rename can succeed","Free disk space and fix write permissions on the data directory","Rename the broken db manually to a .maybe-broken name so the app creates a fresh one","Ensure the data dir sits on a local, writable volume"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: can we write next to the db?\nlet probe = db_path.with_extension(\"rename-probe\");\nstd::fs::write(&probe, b\"\")?;\nstd::fs::remove_file(&probe)?;","typeGuard":null,"tryCatchPattern":"match open_db_with_recovery(&db_path) {\n    Err(e) if e.to_string().contains(\"Failed to rename\") => {\n        // quarantine blocked: report which process may hold the file,\n        // offer a manual move; never delete the db\n    }\n    r => r,\n}","preventionTips":["Exclude the app data dir from real-time AV and backup scans","Run one app instance","Keep the data dir on a local writable disk with free space","Do not hold the db open with external SQLite tooling while the app starts"],"tags":["database","sqlite","startup","filesystem","recovery"],"backgroundTag":"file-rename-failed","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}