gitbutlerapp/gitbutler · error · anyhow::Error

Setup completed but project still not found at {}

Error message

Setup completed but project still not found at {}

What it means

An invariant check after interactive repair: setup ran (via find_or_initialize_repo) and reported success, but re-reading LegacyProject::find_by_worktree_dir still finds no project record for that worktree. The persistent project store (projects.json in the app data dir) and the filesystem disagree.

Source

Thrown at crates/but/src/setup.rs:193

                        let message =
                            format!("No GitButler project found at {}", workdir.display());
                        match prompt_for_setup(out, &message) {
                            SetupPromptResult::RunSetup => {
                                // Run setup
                                let mut ctx = Context::from_repo_with_settings(
                                    repo.clone(),
                                    app_settings.clone(),
                                )?;
                                let mut guard = ctx.exclusive_worktree_access();
                                crate::command::legacy::setup::repo(
                                    &mut ctx,
                                    &args.current_dir,
                                    out,
                                    guard.write_permission(),
                                )?;
                                // Retry finding the project after setup
                                LegacyProject::find_by_worktree_dir(workdir).map_err(|_| {
                                    anyhow::anyhow!(
                                        "Setup completed but project still not found at {}",
                                        workdir.display()
                                    )
                                })?
                            }
                            SetupPromptResult::Declined => {
                                anyhow::bail!(
                                    "Setup required: {message} - run `but setup` to configure the project"
                                );
                            }
                        }
                    }
                };

                // Check project setup, prompt for setup if needed
                let mut ctx =
                    Context::new_from_legacy_project_and_settings(&project, app_settings.clone())?;
                {

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Run `but setup` manually from the same directory, then retry the original command
  2. Inspect the projects store (projects.json in the GitButler app data dir) and confirm the worktree_dir entry matches the real path (compare `pwd -P` with `pwd`)
  3. Access the repo via its canonical non-symlinked path; do not run the desktop app and CLI setup at the same time
  4. As a last resort, remove the stale entry or projects file so it is recreated cleanly (back it up first)
Defensive patterns

Strategy: validation

Validate before calling

if LegacyProject::find_by_worktree_dir(&workdir).is_err() {
    anyhow::bail!(
        "no GitButler project for {}; run `but setup` first",
        workdir.display()
    );
}

Try / catch

When this fires, do not blindly retry the original command: verify the projects.json entry matches the resolved worktree path, fix the mismatch, then rerun setup and the command.

Prevention

When it happens

Trigger: Accepting the 'run setup' repair prompt; setup completes Ok yet the project list was not updated: the recorded worktree_dir does not match the current path spelling (symlink vs resolved), the store is read-only, or a concurrent GitButler app instance rewrote it.

Common situations: Worktree reached through a symlinked path so lookup by path misses; desktop app and CLI racing on the projects store; damaged or stale projects.json.

Related errors


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