gitbutlerapp/gitbutler · critical

There were already backup project files - giving up

Error message

There were already {max_attempts} backup project files - giving up

What it means

At startup, GitButler's project Controller validates the projects database file. If the file is corrupt/unreadable, it moves it aside to a numbered backup (projects.backup.N) and starts fresh. If it fails to create a fresh backup after max_attempts tries (backup names already taken or rename keeps failing), it gives up with this error rather than risk data loss or an unusable state.

Solutions

  1. Inspect the projects storage directory and delete or archive old projects.backup.* files so a fresh backup slot is available.
  2. Check filesystem permissions and free disk space; the rename of the projects file must be able to succeed.
  3. Restore the projects file from a known-good backup, or delete the corrupt projects file (losing project list) and let the app recreate it.
  4. Close file-locking programs (sync clients, editors, antivirus) and restart the app.

Example fix

// Too many stale backups block recovery
$ ls ~/.local/share/gitbutler/projects.backup.*
// after
$ mkdir -p ~/backup-archive
$ mv ~/.local/share/gitbutler/projects.backup.* ~/backup-archive/
Defensive patterns

Strategy: validation

Validate before calling

let dir = projects_path.parent().unwrap();
let stale: Vec<_> = std::fs::read_dir(dir)?
    .filter_map(|e| e.ok())
    .filter(|e| e.file_name().to_string_lossy().starts_with("projects.backup."))
    .collect();
if stale.len() >= max_attempts {
    // archive stale backups before startup recovery runs
}

Prevention

When it happens

Trigger: Calling assure_app_can_startup_or_fix_it when the projects file fails to load AND each attempted backup path (projects.backup.0..N) already exists or the rename to backup cannot succeed for max_attempts consecutive tries.

Common situations: Corrupted projects database after a crash or disk-full; many stale projects.backup.* files left over from repeated failed startups; read-only filesystem or permissions blocking renames; sync tools (Dropbox) locking the projects file.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at crates/gitbutler-project/src/controller.rs:156

                    if backup_path.is_file() {
                        continue;
                    }

                    if let Err(err) = std::fs::rename(&projects_path, &backup_path) {
                        tracing::error!(
                            "Failed to rename {} to {} - application may fail to startup: {err}",
                            projects_path.display(),
                            backup_path.display()
                        );
                    }

                    bail!(
                        "Could not open projects file at '{}'.\nIt was moved to {}.\nReopen or refresh the app to start fresh.\nError was: {probably_file_load_err}",
                        projects_path.display(),
                        backup_path.display()
                    );
                }
                bail!("There were already {max_attempts} backup project files - giving up")
            }
        }
    }
}

impl Controller {
    pub(crate) fn from_path(path: impl Into<PathBuf>) -> Self {
        let path = path.into();
        Self {
            projects_storage: storage::Storage::from_path(&path),
            local_data_dir: path,
        }
    }

    pub(crate) fn add_with_best_effort<P: AsRef<Path>>(
        &self,
        worktree_dir: P,
    ) -> Result<AddProjectOutcome> {

View on GitHub (pinned to 58e5313667)