gitbutlerapp/gitbutler · error
project path is not a directory
Error message
project path is not a directory
What it means
try_project maps AddProjectOutcome::NotADirectory to this error. The given path exists but is a regular file (or other non-directory), so it cannot be a project worktree. GitButler only accepts directories containing git repositories.
Solutions
- Pass the repository's working directory, not a file inside it.
- For a linked worktree, use the worktree's own root directory (GitButler only supports main worktrees — see NonMainWorktree).
- Guard with a check that the path is a directory before adding.
Example fix
// before
let project = add_project(selected_path)?.try_project()?;
// after
if !selected_path.is_dir() {
return Err(format!("{} is not a directory", selected_path.display()).into());
}
let project = add_project(selected_path)?.try_project()?; Defensive patterns
Strategy: validation
Validate before calling
if !path.is_dir() {
return Err(format!("{} is not a directory", path.display()));
} Try / catch
match outcome.try_project() {
Err(e) if e.to_string() == "project path is not a directory" => {
// ask user to select a folder, not a file
show_folder_picker()?;
}
other => other,
} Prevention
- Select folders, not files, in pickers and drag-and-drop.
- Filter file pickers to directories only.
- Remember the `.git` entry of a worktree is a file — pass the worktree root instead.
When it happens
Trigger: Passing a file path (e.g. a .git file from a worktree, a tarball, or any regular file) to the add-project flow instead of a directory.
Common situations: Selecting the `.git` file of a linked worktree, dragging a file instead of a folder, scripts that pass a config or archive path by mistake.
Related errors
- project path not found
- ' ' is not a directory
- Cannot attempt to open anything but a directory
- CLI destination must be absolute
- CLI source path must be absolute
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/035a778e7ac88ce5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-project/src/project.rs:321
/// This is for tests only.
///
/// Unwraps the `Project` if the project was actually added.
/// Panics if it was not.
pub fn unwrap_project(self) -> Project {
match self {
AddProjectOutcome::Added(p) => p,
_ => panic!("called `AddProjectOutcome::unwrap_project()` on a non-project outcome"),
}
}
/// Try to get the `Project`, returning an error if it was not added.
pub fn try_project(self) -> anyhow::Result<Project> {
match self {
AddProjectOutcome::Added(p) => Ok(p),
AddProjectOutcome::AlreadyExists(_) => Err(anyhow::anyhow!("project already exists")),
AddProjectOutcome::PathNotFound => Err(anyhow::anyhow!("project path not found")),
AddProjectOutcome::NotADirectory => {
Err(anyhow::anyhow!("project path is not a directory"))
}
AddProjectOutcome::BareRepository => {
Err(anyhow::anyhow!("bare repositories are not supported"))
}
AddProjectOutcome::NonMainWorktree => {
Err(anyhow::anyhow!("non-main worktrees are not supported"))
}
AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!("no workdir found for repository")),
AddProjectOutcome::NoDotGitDirectory => {
Err(anyhow::anyhow!("no .git directory found in repository"))
}
AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(
"unsupported repository reference format: reftable"
)),
AddProjectOutcome::NotAGitRepository(msg) => {
Err(anyhow::anyhow!("not a git repository: {msg}"))
}
}View on GitHub (pinned to 58e5313667)