{"record":{"id":"8e3f82b058dcce8a","repo":"gitbutlerapp/gitbutler","slug":"repository-has-no-working-directory","errorCode":null,"errorMessage":"Repository has no working directory","messagePattern":"Repository has no working directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/setup.rs","lineNumber":588,"sourceCode":"    if ws.push_remote_name().is_none()\n        && repo\n            .remote_default_name(gix::remote::Direction::Push)\n            .is_none()\n    {\n        anyhow::bail!(\n            \"Neither found push remote found in workspace nor unambiguously in the Git repository configuration.\"\n        )\n    };\n\n    Ok(true)\n}\n\n/// Creates a 'gb-local' remote pointing to this repository and creates tracking refs for the default branch.\nfn setup_local_remote(repo: &gix::Repository, out: &mut OutputChannel) -> anyhow::Result<String> {\n    let t = theme::get();\n    let repo_url = repo\n        .workdir()\n        .ok_or_else(|| anyhow::anyhow!(\"Repository has no working directory\"))?\n        .to_str()\n        .ok_or_else(|| anyhow::anyhow!(\"Repository path is not valid UTF-8\"))?;\n\n    if let Some(out) = out.for_human() {\n        writeln!(\n            out,\n            \"  {}\",\n            t.info\n                .paint(\"No push remote found, creating gb-local remote...\")\n        )?;\n    }\n\n    edit_repo_config(repo, gix::config::Source::Local, |config| {\n        let mut section = config.section_mut_or_create_new(\"remote\", Some(\"gb-local\".into()))?;\n        section.push(\"url\", repo_url)?;\n        Ok(())\n    })?;\n","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/setup.rs#L570-L606","documentation":"Thrown by `setup_local_remote` when `repo.workdir()` returns `None`. Creating the `gb-local` remote requires a filesystem path for the working directory; a bare or workdir-less repository has none, so setup aborts.","triggerScenarios":"Running `but setup` on a repository where gix reports no working directory (bare repo, `core.bare=true`, or repo opened without a worktree) during local-remote setup.","commonSituations":"Setup invoked against a bare clone; `.git/config` with `bare = true` in a checked-out repo; unusual worktree setups where gix cannot resolve the workdir.","solutions":["Ensure the repo is non-bare: `git config core.bare false` if applicable.","Run setup from the main, checked-out clone of the repository.","Re-clone the repository to restore a valid working directory."],"exampleFix":"// before\ncd ~/myrepo.git && but setup\n// after\ngit clone ~/myrepo.git ~/myrepo\ncd ~/myrepo && but setup","handlingStrategy":"validation","validationCode":"const toplevel = await run(['git', '-C', repoPath, 'rev-parse', '--show-toplevel']);\nif (!toplevel.trim()) {\n  throw new Error(`${repoPath} has no working directory; use a non-bare clone`);\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('Setup requires a non-bare clone with a checked-out worktree.');\n  }\n  throw e;\n}","preventionTips":["Always run setup from a normal (non-bare) clone.","Check core.bare is false before onboarding.","Avoid running setup on repo mirrors or server paths."],"tags":["git","bare-repository","cli","setup"],"backgroundTag":"incompatible-source-type","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"}