zed-industries/zed · error · GitBinaryCommandError
Git command failed: {stdout}{stderr}
Error message
Git command failed:
{stdout}{stderr}
What it means
Thrown when a spawned `git hash-object -w --stdin --path` child process exits with a non-zero status while computing the blob SHA for a staged file. It wraps the git stdout/stderr and exit status in GitBinaryCommandError, so it fires when git rejects the path (e.g. file missing from disk, outside the worktree, or a bad index state).
Source
Thrown at crates/git/src/repository.rs:1645
let output = command.output().await?;
anyhow::ensure!(
output.status.success(),
GitBinaryCommandError {
stdout: String::from_utf8_lossy(&output.stdout).to_string(),
stderr: String::from_utf8_lossy(&output.stderr).to_string(),
status: output.status,
}
);
Ok(output.stdout)
})
.boxed()
}
fn load_commit_template(&self) -> BoxFuture<'_, Result<Option<GitCommitTemplate>>> {
let working_directory = self.working_directory();
let git_binary = self.git_binary_in_worktree();
self.executor
.spawn(async move {
let working_directory = working_directory?;
let git_binary = git_binary?;
let output = git_binary
.build_command(&["config", "--get", "commit.template"])
.output()
.await
.context("failed to run git config --get commit.template")?;
let raw_path = String::from_utf8_lossy(&output.stdout).trim().to_string();
if !output.status.success() || raw_path.is_empty() {
return Ok(None);
}
let path = PathBuf::from(&raw_path);
let path = if let Some(path) = raw_path.strip_prefix("~/") {
paths::home_dir().join(path)
} else if path.is_relative() {View on GitHub (pinned to 5a9b9558db)
Solutions
- Check stderr in the error for git's actual complaint (path not found, bad object, permission denied)
- Verify the file still exists on disk and is readable before hashing
- Confirm the path is inside the repository worktree and correctly encoded
- Retry the operation; transient index/lock contention can cause git to fail
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/git/src/repository.rs:1634 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20).
Data as JSON: /api/errors/cf5c5be375f26c9d.
Report an issue: GitHub.