{"record":{"id":"2e9509591c6ad17a","repo":"gitbutlerapp/gitbutler","slug":"could-not-create-repository-bundle","errorCode":null,"errorMessage":"Could not create repository bundle: {}","messagePattern":"Could not create repository bundle: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-debug/src/command/dump/repo_installer.rs","lineNumber":189,"sourceCode":"        .map(|name| {\n            name.as_bstr()\n                .to_str()\n                .context(\"HEAD reference name is not UTF-8\")\n                .map(ToOwned::to_owned)\n        })\n        .transpose()?;\n    Ok((oid, reference))\n}\n\nfn create_bundle(workdir: &Path, bundle_path: &Path) -> Result<()> {\n    let output = git_command(workdir)?\n        .args([\"bundle\", \"create\", \"--quiet\"])\n        .arg(bundle_path)\n        .args([\"--all\", \"HEAD\", \"--not\", \"--remotes\"])\n        .output()\n        .context(\"Could not start git bundle creation\")?;\n    if !output.status.success() {\n        bail!(\n            \"Could not create repository bundle: {}\",\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    Ok(())\n}\n\nfn selected_local_config(workdir: &Path) -> Result<Vec<u8>> {\n    let output = git_command(workdir)?\n        .args([\n            \"config\",\n            \"--local\",\n            \"--includes\",\n            \"--null\",\n            \"--get-regexp\",\n            r\"^(gitbutler\\.|remote\\.|log\\.excludedecoration$)\",\n        ])\n        .output()","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-debug/src/command/dump/repo_installer.rs#L171-L207","documentation":"create_bundle shells out to `git bundle create --quiet <path> --all HEAD --not --remotes` to build a repository bundle. If git exits non-zero, the function bails including git's trimmed stderr, so the underlying git error is surfaced verbatim.","triggerScenarios":"Calling create_bundle (from run) where the spawned `git bundle create` process returns a non-zero exit status — e.g. a repository with no HEAD/commits, a corrupt object database, or an unwritable bundle_path.","commonSituations":"Bare/empty repository with no HEAD commit to bundle, read-only or missing target directory for the bundle file, broken refs (`--all` failing on a malformed ref), or git not able to read the object store (corruption, wrong workdir).","solutions":["Read the stderr in the message for the underlying git failure and fix that cause (e.g. bad ref, permission)","Verify the repository has at least one commit reachable from HEAD before bundling","Check that bundle_path's parent directory exists and is writable","Run `git bundle create <path> --all HEAD --not --remotes` manually in the repo to reproduce and diagnose","Run `git fsck` if object corruption is reported"],"exampleFix":"// before\n// failing: empty repo, no HEAD\ncreate_bundle(repo_path, bundle_path)?;\n// after\nif repo.head_id().is_err() {\n    anyhow::bail!(\"repository has no commits; nothing to bundle\");\n}\ncreate_bundle(repo_path, bundle_path)?;","handlingStrategy":"try-catch","validationCode":"let has_head = Command::new(\"git\").arg(\"rev-parse\").arg(\"HEAD\")\n    .current_dir(&repo_path).output()?.status.success();\nif !has_head { anyhow::bail!(\"repo has no HEAD; nothing to bundle\"); }","typeGuard":null,"tryCatchPattern":"match installer.create_bundle(&repo_path, &bundle_path) {\n    Err(e) if e.to_string().contains(\"Could not create repository bundle\") => {\n        eprintln!(\"git bundle failed: {e}; check refs/permissions and run git fsck\");\n    }\n    other => other?,\n}","preventionTips":["Verify HEAD resolves and the object store is healthy (git fsck) before bundling","Ensure the bundle output directory exists and is writable","Keep git installed and on PATH at a supported version"],"tags":["git","bundle","cli","subprocess"],"backgroundTag":"git-command-failed","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"}