{"record":{"id":"751b723c4c52fa62","repo":"gitbutlerapp/gitbutler","slug":"could-not-list-repository-local-git-environment-variables","errorCode":null,"errorMessage":"Could not list repository-local Git environment variables: {}","messagePattern":"Could not list repository-local Git environment variables: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-debug/src/command/dump/repo_installer.rs","lineNumber":276,"sourceCode":"}\n\nfn is_storage_path_key(key: &[u8]) -> bool {\n    [\n        b\"gitbutler.storagepath\".as_slice(),\n        b\"gitbutler.nightly.storagepath\".as_slice(),\n        b\"gitbutler.dev.storagepath\".as_slice(),\n    ]\n    .iter()\n    .any(|candidate| key.eq_ignore_ascii_case(candidate))\n}\n\nfn git_command(workdir: &Path) -> Result<Command> {\n    let output = Command::new(\"git\")\n        .args([\"rev-parse\", \"--local-env-vars\"])\n        .output()\n        .context(\"Could not list repository-local Git environment variables\")?;\n    if !output.status.success() {\n        bail!(\n            \"Could not list repository-local Git environment variables: {}\",\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n\n    let mut command = Command::new(\"git\");\n    for name in output.stdout.split(|byte| *byte == b'\\n') {\n        if !name.is_empty() {\n            command.env_remove(\n                std::str::from_utf8(name).context(\"Git environment variable name is not UTF-8\")?,\n            );\n        }\n    }\n    command.arg(\"-C\").arg(workdir);\n    Ok(command)\n}\n\nfn ref_manifests(repo: &gix::Repository) -> Result<(Vec<u8>, Vec<u8>)> {","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-debug/src/command/dump/repo_installer.rs#L258-L294","documentation":"git_command prepares a git subprocess isolated from environment variables that alter repository resolution by first running `git rev-parse --local-env-vars` to enumerate them. If that git invocation fails, the function bails with git's trimmed stderr in the message.","triggerScenarios":"Calling git_command(workdir) (used by create_bundle and selected_local_config) when `git rev-parse --local-env-vars` exits non-zero — usually because the git executable is missing/broken or the environment is unusable.","commonSituations":"git not installed or not on PATH for the dump process, a broken git wrapper in PATH, restricted environments (containers/CI) stripping PATH, or an incompatible git version.","solutions":["Ensure git is installed and `git rev-parse --local-env-vars` works in your shell","Fix PATH so the same git the user expects is found by the process","Check GIT_EXEC_PATH and any git wrappers/aliases that could break non-interactive execution","Verify the workdir passed to git_command exists and is accessible"],"exampleFix":"// before\n// git missing from PATH in CI image\nlet cmd = git_command(&workdir)?;\n// after\n// ensure git exists first\nassert!(Command::new(\"git\").arg(\"--version\").output().is_ok(), \"git must be on PATH\");\nlet cmd = git_command(&workdir)?;","handlingStrategy":"fallback","validationCode":"if Command::new(\"git\").arg(\"--version\").output().is_err() {\n    anyhow::bail!(\"git not found on PATH\");\n}","typeGuard":null,"tryCatchPattern":"match git_command(&workdir) {\n    Err(e) if e.to_string().contains(\"Could not list repository-local Git environment variables\") => {\n        eprintln!(\"ensure git is installed and on PATH: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Install git and keep it on PATH in CI/containers","Avoid git wrappers that break non-interactive invocation","Verify GIT_EXEC_PATH points at a working git installation"],"tags":["git","environment","subprocess","path"],"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"}