{"record":{"id":"50cfdead2e8c2ab8","repo":"gitbutlerapp/gitbutler","slug":"repository-installers-require-the-main-worktree","errorCode":null,"errorMessage":"Repository installers require the main worktree","messagePattern":"Repository installers require the main worktree","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-debug/src/command/dump/repo_installer.rs","lineNumber":39,"sourceCode":"/// Execute the `dump repo-installer` subcommand.\npub(super) fn run(\n    args: &Args,\n    installer_args: &RepoInstallerArgs,\n    out: &mut dyn io::Write,\n    err: &mut dyn io::Write,\n) -> Result<()> {\n    let current_dir = effective_current_dir(args)?;\n    let repo = setup::repo_from_args(args).with_context(|| {\n        format!(\n            \"Could not discover Git repository at '{}'\",\n            current_dir.display()\n        )\n    })?;\n    let repo = gix::open_opts(repo.git_dir().canonicalize()?, repo.open_options().clone())?;\n    let workdir = repo\n        .workdir()\n        .context(\"Repository installers require a non-bare repository\")?;\n    ensure!(\n        repo.git_dir() == repo.common_dir(),\n        \"Repository installers require the main worktree\"\n    );\n\n    let project_data_dir = repo\n        .gitbutler_storage_path()\n        .context(\"Could not locate GitButler project data\")?;\n    ensure!(\n        project_data_dir.is_dir(),\n        \"GitButler project data does not exist at '{}'\",\n        project_data_dir.display()\n    );\n\n    let base = archive_base_name(&repo)?;\n    let archive_root = format!(\"{base}-repo-installer\");\n    let output_path = match &installer_args.archive.output {\n        Some(path) => current_dir.join(path),\n        None => default_output_path(&repo, \"repo-installer\")?,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-debug/src/command/dump/repo_installer.rs#L21-L57","documentation":"The `but-debug dump repo-installer` command reconstructs an installer archive for a repository and requires the main worktree. After ensuring a non-bare repo, it asserts repo.git_dir() == repo.common_dir() — i.e. the opened repo is not a linked worktree — and fails with this message otherwise.","triggerScenarios":"Running `but-debug dump repo-installer` from inside a git linked worktree (created via `git worktree add`), where git_dir() is .git/worktrees/<name> and differs from common_dir().","commonSituations":"Developers debugging from a secondary worktree checkout; CI that checks out via `git worktree add`; monorepo workflows that keep multiple worktrees.","solutions":["Run the command from the main worktree of the repository (the one containing the real .git directory).","cd to `git worktree list`'s first (main) entry and re-run.","If only a linked worktree is available, clone/open the primary checkout first."],"exampleFix":"// before\n$ cd ~/work/myrepo-feature-wt && but-debug dump repo-installer\n// after\n$ cd ~/work/myrepo && but-debug dump repo-installer   # main worktree","handlingStrategy":"validation","validationCode":"main_wt=$(git worktree list --porcelain | head -1 | cut -d' ' -f2)\ncd \"$main_wt\" && but-debug dump repo-installer","typeGuard":"fn is_main_worktree(repo: &gix::Repository) -> bool { repo.git_dir() == repo.common_dir() }","tryCatchPattern":null,"preventionTips":["Run repo-installer dumps only from the main worktree (first entry of `git worktree list`).","Check `git rev-parse --git-common-dir` equals `--git-dir` before running.","Avoid CI checkouts via `git worktree add` for debug dumps."],"tags":["git","worktree","cli"],"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"}