gitbutlerapp/gitbutler · error

The path {} is not a directory

Error message

The path {} is not a directory

What it means

Raised while registering a repository during `but setup`: the path exists but is a regular file (or symlink to one), so `gitbutler_project` returned `AddProjectOutcome::NotADirectory`. GitButler project paths must be directories; nothing Git-related is attempted.

Source

Thrown at crates/but/src/command/legacy/setup.rs:238

                )?;
            }
            Ok(ProjectStatus::Added)
        }
        gitbutler_project::AddProjectOutcome::AlreadyExists(_) => {
            if let Some(out) = out.for_human() {
                writeln!(
                    out,
                    "  {}",
                    t.success.paint("✓ Repository already in project registry")
                )?;
            }
            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()

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Point at the directory that contains the repository, not at a file
  2. Verify with `test -d /the/path && echo dir` before running
  3. If the path is a symlink, check what it resolves to (`readlink -f /the/path`)

Example fix

# before: path is a file
but setup ~/repos/my-project/README.md

# after: pass the directory
but setup ~/repos/my-project
Defensive patterns

Strategy: validation

Validate before calling

let meta = std::fs::metadata(&repo_path)?;
if !meta.is_dir() {
    anyhow::bail!("{repo_path:?} is a file; pass the repository directory instead");
}

Type guard

fn is_not_a_directory(out: &gitbutler_project::AddProjectOutcome) -> bool {
    matches!(out, gitbutler_project::AddProjectOutcome::NotADirectory)
}

Try / catch

match add_project(&repo_path) {
    Ok(out) if is_not_a_directory(&out) => { /* ask for the parent directory */ }
    Ok(out) => { /* other outcomes */ }
    Err(err) if err.to_string().contains("is not a directory") => { /* directory guidance */ }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: Passing a file path where the project directory is expected, e.g. pointing at a script, a `.git` pack file, or a symlink that resolves to a file.

Common situations: Copy-pasting a file path from documentation instead of its parent folder; scripts appending a filename to a directory variable; symlinks that changed target type.

Related errors


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