{"record":{"id":"035a778e7ac88ce5","repo":"gitbutlerapp/gitbutler","slug":"project-path-is-not-a-directory","errorCode":null,"errorMessage":"project path is not a directory","messagePattern":"project path is not a directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-project/src/project.rs","lineNumber":321,"sourceCode":"    /// This is for tests only.\n    ///\n    /// Unwraps the `Project` if the project was actually added.\n    /// Panics if it was not.\n    pub fn unwrap_project(self) -> Project {\n        match self {\n            AddProjectOutcome::Added(p) => p,\n            _ => panic!(\"called `AddProjectOutcome::unwrap_project()` on a non-project outcome\"),\n        }\n    }\n\n    /// Try to get the `Project`, returning an error if it was not added.\n    pub fn try_project(self) -> anyhow::Result<Project> {\n        match self {\n            AddProjectOutcome::Added(p) => Ok(p),\n            AddProjectOutcome::AlreadyExists(_) => Err(anyhow::anyhow!(\"project already exists\")),\n            AddProjectOutcome::PathNotFound => Err(anyhow::anyhow!(\"project path not found\")),\n            AddProjectOutcome::NotADirectory => {\n                Err(anyhow::anyhow!(\"project path is not a directory\"))\n            }\n            AddProjectOutcome::BareRepository => {\n                Err(anyhow::anyhow!(\"bare repositories are not supported\"))\n            }\n            AddProjectOutcome::NonMainWorktree => {\n                Err(anyhow::anyhow!(\"non-main worktrees are not supported\"))\n            }\n            AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!(\"no workdir found for repository\")),\n            AddProjectOutcome::NoDotGitDirectory => {\n                Err(anyhow::anyhow!(\"no .git directory found in repository\"))\n            }\n            AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(\n                \"unsupported repository reference format: reftable\"\n            )),\n            AddProjectOutcome::NotAGitRepository(msg) => {\n                Err(anyhow::anyhow!(\"not a git repository: {msg}\"))\n            }\n        }","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-project/src/project.rs#L303-L339","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet project = add_project(selected_path)?.try_project()?;\n// after\nif !selected_path.is_dir() {\n    return Err(format!(\"{} is not a directory\", selected_path.display()).into());\n}\nlet project = add_project(selected_path)?.try_project()?;","handlingStrategy":"validation","validationCode":"if !path.is_dir() {\n    return Err(format!(\"{} is not a directory\", path.display()));\n}","typeGuard":null,"tryCatchPattern":"match outcome.try_project() {\n    Err(e) if e.to_string() == \"project path is not a directory\" => {\n        // ask user to select a folder, not a file\n        show_folder_picker()?;\n    }\n    other => other,\n}","preventionTips":["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."],"tags":["project","path","validation","filesystem"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}