gitbutlerapp/gitbutler · error
Could not list repository-local Git environment variables
Error message
Could not list repository-local Git environment variables: {} What it means
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.
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
Example fix
// before
// git missing from PATH in CI image
let cmd = git_command(&workdir)?;
// after
// ensure git exists first
assert!(Command::new("git").arg("--version").output().is_ok(), "git must be on PATH");
let cmd = git_command(&workdir)?; Defensive patterns
Strategy: fallback
Validate before calling
if Command::new("git").arg("--version").output().is_err() {
anyhow::bail!("git not found on PATH");
} Try / catch
match git_command(&workdir) {
Err(e) if e.to_string().contains("Could not list repository-local Git environment variables") => {
eprintln!("ensure git is installed and on PATH: {e}");
}
other => other?,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- Could not find ' '. Please make sure it is in your `PATH`…
- Could not create repository bundle
- Could not read repository-local Git configuration
- Failed to sign SSH
- not a git repository
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/751b723c4c52fa62.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-debug/src/command/dump/repo_installer.rs:276
}
fn is_storage_path_key(key: &[u8]) -> bool {
[
b"gitbutler.storagepath".as_slice(),
b"gitbutler.nightly.storagepath".as_slice(),
b"gitbutler.dev.storagepath".as_slice(),
]
.iter()
.any(|candidate| key.eq_ignore_ascii_case(candidate))
}
fn git_command(workdir: &Path) -> Result<Command> {
let output = Command::new("git")
.args(["rev-parse", "--local-env-vars"])
.output()
.context("Could not list repository-local Git environment variables")?;
if !output.status.success() {
bail!(
"Could not list repository-local Git environment variables: {}",
String::from_utf8_lossy(&output.stderr).trim()
);
}
let mut command = Command::new("git");
for name in output.stdout.split(|byte| *byte == b'\n') {
if !name.is_empty() {
command.env_remove(
std::str::from_utf8(name).context("Git environment variable name is not UTF-8")?,
);
}
}
command.arg("-C").arg(workdir);
Ok(command)
}
fn ref_manifests(repo: &gix::Repository) -> Result<(Vec<u8>, Vec<u8>)> {View on GitHub (pinned to 58e5313667)