{"record":{"id":"70dbd62a6bb0e8bd","repo":"gitbutlerapp/gitbutler","slug":"no-workdir-found-for-repository","errorCode":null,"errorMessage":"no workdir found for repository","messagePattern":"no workdir found for repository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gitbutler-project/src/project.rs","lineNumber":329,"sourceCode":"        }\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        }\n    }\n}\n","sourceCodeStart":311,"sourceCodeEnd":342,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-project/src/project.rs#L311-L342","documentation":"try_project maps AddProjectOutcome::NoWorkdir to this error. A repository was found at the path, but git reports no working directory (workdir) for it, so GitButler cannot operate on checked-out files. This typically coincides with bare or oddly configured repositories.","triggerScenarios":"Adding a repo whose repository handle opens but `Repository::workdir()` returns None — bare repos, or repos with a corrupted `core.worktree`/missing core.bare configuration after manual .git manipulation.","commonSituations":"Hand-edited .git/config removing worktree settings; repos converted to/from bare; .git directories copied out of context; container or CI artifacts with incomplete checkouts.","solutions":["Re-clone the repository into a fresh working directory and add that instead.","Inspect `.git/config`: ensure `bare = false` and `core.worktree` is unset or correct for a normal clone.","Verify with `git -C <path> rev-parse --show-toplevel` that a toplevel exists before adding.","Restore .git/config from a backup if it was manually modified."],"exampleFix":"// before\nlet project = add_project(repo_path)?.try_project()?;\n// after\nlet toplevel = Command::new(\"git\")\n    .args([\"rev-parse\", \"--show-toplevel\"])\n    .current_dir(&repo_path)\n    .output()?;\nif !toplevel.status.success() {\n    return Err(\"repository has no working directory; re-clone it\".into());\n}\nlet project = add_project(repo_path)?.try_project()?;","handlingStrategy":"validation","validationCode":"let out = std::process::Command::new(\"git\")\n    .args([\"rev-parse\", \"--show-toplevel\"])\n    .current_dir(path)\n    .output()?;\nif !out.status.success() {\n    return Err(\"repository has no working directory\".into());\n}","typeGuard":null,"tryCatchPattern":"match outcome.try_project() {\n    Err(e) if e.to_string() == \"no workdir found for repository\" => {\n        // guide user to re-clone the repo with a working tree\n        offer_reclone_flow(&path)?;\n    }\n    other => other,\n}","preventionTips":["Don't hand-edit `.git/config` (core.bare / core.worktree) on working clones.","Verify `git rev-parse --show-toplevel` works in the folder before adding.","Re-clone rather than copying .git directories out of context."],"tags":["git","project","workdir","repository"],"backgroundTag":"missing-workdir","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"}