{"record":{"id":"3c49a4231cababaa","repo":"Hmbown/CodeWhale","slug":"failed-to-run-git-diff-is-git-installed-e","errorCode":null,"errorMessage":"Failed to run git diff. Is git installed? ({e})","messagePattern":"Failed to run git diff\\. Is git installed\\? \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":9855,"sourceCode":"        )?\n    } else {\n        let mut cmd = crate::dependencies::Git::review_command(workspace)?;\n        // Review repository content without executing its diff drivers.\n        cmd.current_dir(workspace)\n            .args([\"diff\", \"--no-ext-diff\", \"--no-textconv\"]);\n        if args.staged {\n            cmd.arg(\"--cached\");\n        }\n        if let Some(base) = &args.base {\n            cmd.arg(format!(\"{base}...HEAD\"));\n        }\n        if let Some(path) = &args.path {\n            cmd.arg(\"--\").arg(path);\n        }\n\n        let output = cmd\n            .output()\n            .map_err(|e| anyhow::anyhow!(\"Failed to run git diff. Is git installed? ({e})\"))?;\n        if !output.status.success() {\n            let stderr = String::from_utf8_lossy(&output.stderr);\n            bail!(\"git diff failed: {}\", stderr.trim());\n        }\n        String::from_utf8_lossy(&output.stdout).to_string()\n    };\n    if args.pr.is_none() {\n        ensure_local_review_diff_fits(&diff, args.max_chars)?;\n    }\n    Ok(diff)\n}\n\nfn ensure_local_review_diff_fits(diff: &str, max_chars: usize) -> Result<()> {\n    let chars = diff.chars().count();\n    if chars > max_chars {\n        bail!(\n            \"Complete local diff requires {chars} characters, exceeding the review limit of {max_chars}. No review was run and no receipt was written or accepted. Select an explicit --path scope, or increase --max-chars only if the selected model can accept the complete input.\"\n        );","sourceCodeStart":9837,"sourceCodeEnd":9873,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L9837-L9873","documentation":"Thrown when spawning the external `git diff` command fails at the OS level — the error message explicitly hints that git may not be installed. This wraps std::io::Error from `cmd.output()`, meaning the process could not be started at all (as opposed to git running but returning a non-zero exit, which produces the separate 'git diff failed: <stderr>' error).","triggerScenarios":"`cmd.output()` errors when running `git diff` (with optional `-- <path>` args) — git binary missing from PATH, no exec permission, or the executable path is invalid.","commonSituations":"Fresh Docker/CI containers without git installed; minimal Windows or macOS environments lacking developer tools; a PATH that excludes /usr/bin in the sandbox or service context; a corrupted git installation.","solutions":["Install git (`apt-get install git`, `brew install git`, `winget install Git.Git`)","Check `git --version` in the same shell/PATH context the app runs in","Fix PATH for the service/container so it includes the directory containing git","If git exists but lacks +x, chmod +x the binary or reinstall"],"exampleFix":"// before\nlet output = cmd.output()\n    .map_err(|e| anyhow::anyhow!(\"Failed to run git diff. Is git installed? ({e})\"))?;\n// after\n// ensure git is present first\nif which::which(\"git\").is_err() { bail!(\"git is not installed or not on PATH\"); }\nlet output = cmd.output()\n    .map_err(|e| anyhow::anyhow!(\"Failed to run git diff. Is git installed? ({e})\"))?;","handlingStrategy":"fallback","validationCode":"// Rust\nlet git_ok = std::process::Command::new(\"git\").arg(\"--version\").output()\n    .map(|o| o.status.success()).unwrap_or(false);\nif !git_ok { eprintln!(\"git is not installed or not on PATH\"); }","typeGuard":null,"tryCatchPattern":"// Rust\nmatch get_diff(args) {\n    Ok(diff) => diff,\n    Err(e) if e.to_string().contains(\"Is git installed\") => {\n        eprintln!(\"git missing: {e:#}\");\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Install git in Docker/CI base images","Assert `git --version` in environment smoke tests at startup","Keep a normal PATH in services and sandboxed executors","Document the git dependency in setup docs"],"tags":["git","command-not-found","process"],"backgroundTag":"command-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}