{"record":{"id":"0db6cb19216358fd","repo":"gitbutlerapp/gitbutler","slug":"the-repository-at-has-no-working-directory-git","errorCode":null,"errorMessage":"The repository at {} has no working directory. GitButler requires a working directory.","messagePattern":"The repository at (.+?) has no working directory\\. GitButler requires a working directory\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":250,"sourceCode":"            Ok(ProjectStatus::AlreadyExists)\n        }\n        gitbutler_project::AddProjectOutcome::PathNotFound => Err(anyhow::anyhow!(\n            \"The path {} does not exist\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NotADirectory => Err(anyhow::anyhow!(\n            \"The path {} is not a directory\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::BareRepository => Err(anyhow::anyhow!(\n            \"The repository at {} is bare. GitButler requires a non-bare repository.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NonMainWorktree => Err(anyhow::anyhow!(\n            \"The repository at {} is a non-main worktree. GitButler requires the main worktree.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NoWorkdir => Err(anyhow::anyhow!(\n            \"The repository at {} has no working directory. GitButler requires a working directory.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NoDotGitDirectory => Err(anyhow::anyhow!(\n            \"The repository at {} has no .git directory. GitButler requires a .git directory.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::ReftableRefFormatUnsupported => Err(anyhow::anyhow!(\n            \"The repository at {} uses the currently unsupported reftable reference format.\",\n            repo_path.display()\n        )),\n        gitbutler_project::AddProjectOutcome::NotAGitRepository(_) => Err(anyhow::anyhow!(\n            \"The path {} is not a git repository.\",\n            repo_path.display()\n        )),\n    }?;\n\n    // A ported project can keep its target in Git config while the legacy `virtual_branches.toml`","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/setup.rs#L232-L268","documentation":"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.","triggerScenarios":"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.","commonSituations":"GIT_DIR/GIT_WORK_TREE environment leaks from other tooling; unusual repo layouts produced by filters or wrappers; partially copied repositories missing the worktree.","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"],"exampleFix":"# before: leaked GIT_DIR points at a worktree-less core\nGIT_DIR=/srv/git/project.git but setup ~/work/project\n\n# after: clean environment\nunset GIT_DIR GIT_WORK_TREE\nbut setup ~/work/project","handlingStrategy":"validation","validationCode":"let repo = gix::discover(&repo_path)?;\nif repo.workdir().is_none() {\n    anyhow::bail!(\"repository has no working directory; check GIT_DIR/GIT_WORK_TREE env\");\n}","typeGuard":"fn is_no_workdir(out: &gitbutler_project::AddProjectOutcome) -> bool {\n    matches!(out, gitbutler_project::AddProjectOutcome::NoWorkdir)\n}","tryCatchPattern":"match add_project(&repo_path) {\n    Ok(out) if is_no_workdir(&out) => { /* fix env or re-clone */ }\n    Ok(out) => { /* other outcomes */ }\n    Err(err) if err.to_string().contains(\"no working directory\") => { /* worktree guidance */ }\n    Err(err) => return Err(err),\n}","preventionTips":["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"],"tags":["rust","cli","setup","git","worktree","environment"],"backgroundTag":"git-no-worktree","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}