gitbutlerapp/gitbutler · error
The repository at {} has no working directory. GitButler req
Error message
The repository at {} has no working directory. GitButler requires a working directory. What it means
Raised while registering a repository: the path passed earlier checks but `gitbutler_project` could not obtain a working directory for it (`AddProjectOutcome::NoWorkdir`). Practically this is the bare-adjacent case — a repository record exists but there is no worktree root for GitButler to manage.
Source
Thrown at crates/but/src/command/legacy/setup.rs:250
Ok(ProjectStatus::AlreadyExists)
}
gitbutler_project::AddProjectOutcome::PathNotFound => Err(anyhow::anyhow!(
"The path {} does not exist",
repo_path.display()
)),
gitbutler_project::AddProjectOutcome::NotADirectory => Err(anyhow::anyhow!(
"The path {} is not a directory",
repo_path.display()
)),
gitbutler_project::AddProjectOutcome::BareRepository => Err(anyhow::anyhow!(
"The repository at {} is bare. GitButler requires a non-bare repository.",
repo_path.display()
)),
gitbutler_project::AddProjectOutcome::NonMainWorktree => Err(anyhow::anyhow!(
"The repository at {} is a non-main worktree. GitButler requires the main worktree.",
repo_path.display()
)),
gitbutler_project::AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!(
"The repository at {} has no working directory. GitButler requires a working directory.",
repo_path.display()
)),
gitbutler_project::AddProjectOutcome::NoDotGitDirectory => Err(anyhow::anyhow!(
"The repository at {} has no .git directory. GitButler requires a .git directory.",
repo_path.display()
)),
gitbutler_project::AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(
"The repository at {} uses the currently unsupported reftable reference format.",
repo_path.display()
)),
gitbutler_project::AddProjectOutcome::NotAGitRepository(_) => Err(anyhow::anyhow!(
"The path {} is not a git repository.",
repo_path.display()
)),
}?;
// A ported project can keep its target in Git config while the legacy `virtual_branches.toml`View on GitHub (pinned to caf1f223d3)
Solutions
- Verify what git itself sees: `git -C /the/path rev-parse --show-toplevel` — if it errors or prints the wrong root, the worktree association is broken
- Unset GIT_DIR / GIT_WORK_TREE / GIT_INDEX_FILE from the environment and retry
- If the layout is genuinely bare-like, re-clone as a normal working copy and register that
Example fix
# before: leaked GIT_DIR points at a worktree-less core GIT_DIR=/srv/git/project.git but setup ~/work/project # after: clean environment unset GIT_DIR GIT_WORK_TREE but setup ~/work/project
Defensive patterns
Strategy: validation
Validate before calling
let repo = gix::discover(&repo_path)?;
if repo.workdir().is_none() {
anyhow::bail!("repository has no working directory; check GIT_DIR/GIT_WORK_TREE env");
} Type guard
fn is_no_workdir(out: &gitbutler_project::AddProjectOutcome) -> bool {
matches!(out, gitbutler_project::AddProjectOutcome::NoWorkdir)
} Try / catch
match add_project(&repo_path) {
Ok(out) if is_no_workdir(&out) => { /* fix env or re-clone */ }
Ok(out) => { /* other outcomes */ }
Err(err) if err.to_string().contains("no working directory") => { /* worktree guidance */ }
Err(err) => return Err(err),
} Prevention
- Unset GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE before running repo tools
- Validate with `git rev-parse --show-toplevel` that a worktree root resolves
- Avoid hand-rolled repo layouts; use standard clones
When it happens
Trigger: Setup against a repo whose discovered core has no worktree attached: a bare-style layout, a `.git` pointer whose target lacks a worktree, or a repo opened through GIT_DIR-only semantics without a matching GIT_WORK_TREE.
Common situations: GIT_DIR/GIT_WORK_TREE environment leaks from other tooling; unusual repo layouts produced by filters or wrappers; partially copied repositories missing the worktree.
Related errors
- The repository at {} is a non-main worktree. GitButler requi
- The repository at {} is bare. GitButler requires a non-bare
- The repository at {} has no .git directory. GitButler requir
- The repository at {} uses the currently unsupported reftable
- The path {} is not a git repository.
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/0db6cb19216358fd.
Report an issue: GitHub.