nikivdev/code · error

git {} failed

Error message

git {} failed

What it means

Raised by a git helper in src/sync.rs when a git command fails but produced no stdout or stderr detail at all. The library can only report `git <args> failed` without a reason, since detail (trimmed stdout+stderr) was empty. This is the no-detail variant of the git failure error (919).

Source

Thrown at src/sync.rs:5133

fn git_run_captured_in(repo_root: &Path, args: &[&str]) -> Result<()> {
    let output = Command::new("git")
        .current_dir(repo_root)
        .args(args)
        .output()
        .context("failed to run git")?;

    if output.status.success() {
        return Ok(());
    }

    let stdout = String::from_utf8_lossy(&output.stdout);
    let stderr = String::from_utf8_lossy(&output.stderr);
    let detail = format!("{}\n{}", stdout.trim(), stderr.trim())
        .trim()
        .to_string();
    if detail.is_empty() {
        bail!("git {} failed", args.join(" "));
    }
    bail!("git {} failed: {}", args.join(" "), detail);
}

fn restore_stash_result(
    repo_root: &Path,
    auto_stash_state: &AutoStashState,
    allow_autofix: bool,
) -> Result<()> {
    restore_stash_result_with_packet_dir(repo_root, auto_stash_state, allow_autofix, None)
}

fn restore_stash_result_with_packet_dir(
    repo_root: &Path,
    auto_stash_state: &AutoStashState,
    allow_autofix: bool,
    packet_dir_override: Option<&Path>,
) -> Result<()> {

View on GitHub (pinned to a747e741ae)

Solutions

  1. Re-run the same git command (`git <args>` from the message) in the repo to see if it emits output now
  2. Check exit conditions: permissions on .git, disk space, and signal kills (dmesg/OOM killer)
  3. Verify the git binary version and that the repo is not corrupted (`git fsck`)
  4. Retry the sync once the environment issue is resolved
Defensive patterns

Strategy: retry

Validate before calling

// preflight: confirm git runs and repo is intact
let v = std::process::Command::new("git").arg("--version").output()?;
if !v.status.success() {
    eprintln!("git binary failing with no output; check permissions, disk, OOM");
}
let fsck = std::process::Command::new("git").args(["fsck", "--no-progress"]).output()?;
if !fsck.status.success() {
    eprintln!("Repository corruption detected; repair before syncing");
}

Try / catch

// no detail is available, so retry with manual reproduction
match sync_result {
    Err(e) if e.to_string().starts_with("git ") && e.to_string().ends_with("failed") => {
        eprintln!("{e}; re-run the same git command manually to get diagnostics");
    }
    other => other?,
}

Prevention

When it happens

Trigger: A git invocation in the sync flow exits non-zero and both stdout and stderr are empty/whitespace after trimming, so the detail string is empty.

Common situations: git binary killed by a signal (no output); very old git versions failing silently; I/O or permission problems that prevent git from writing diagnostics.

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


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/827807d2df077311. Report an issue: GitHub.