{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":269,"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":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/setup.rs#L251-L287","documentation":"Thrown when `AddProjectOutcome::NoWorkdir` is returned. The repository resolves but `git` reports no working directory (core.bare semantics or an unusual setup), so GitButler cannot manage files in the working tree.","triggerScenarios":"Running setup on a repo whose working directory cannot be resolved (e.g. `core.bare = true` set on a non-bare-looking repo, or a stripped checkout).","commonSituations":"Manually toggling `core.bare` in `.git/config`; broken or partially deleted checkouts; repos migrated by tools that dropped the worktree config.","solutions":["Check `git config core.bare` in the repo; set it to false if wrongly enabled: `git config core.bare false`.","Re-clone the repository to restore a healthy working directory.","Verify `git rev-parse --show-toplevel` returns a path before running setup."],"exampleFix":"// before\ncore.bare = true\n// after\ngit config core.bare false","handlingStrategy":"validation","validationCode":"const bare = await run(['git', '-C', repoPath, 'config', '--get', 'core.bare']);\nconst toplevel = await run(['git', '-C', repoPath, 'rev-parse', '--show-toplevel']);\nif (bare.trim() === 'true' || !toplevel.trim()) {\n  throw new Error(`${repoPath} has no working directory`);\n}","typeGuard":"function hasWorkdir(p: string): boolean {\n  const r = cp.spawnSync('git', ['-C', p, 'rev-parse', '--show-toplevel']);\n  return r.status === 0 && r.stdout.toString().trim().length > 0;\n}","tryCatchPattern":"try {\n  await run(['but', 'setup', repoPath]);\n} catch (e) {\n  if (String(e).includes('no working directory')) {\n    console.error('Check core.bare and re-clone if the checkout is broken.');\n  }\n  throw e;\n}","preventionTips":["Never hand-edit core.bare in a working clone.","Validate `git rev-parse --show-toplevel` succeeds in CI before setup.","Re-clone rather than repairing partially deleted checkouts."],"tags":["git","workdir","cli","setup"],"backgroundTag":"invalid-state-transition","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"}