{"record":{"id":"a0db4c376dcd7ea2","repo":"denoland/deno","slug":"failed-to-run-git-err-is-git-installed-an","errorCode":null,"errorMessage":"Failed to run `git {}`: {err}. Is git installed and on PATH?","messagePattern":"Failed to run `git (.+?)`: (.+?)\\. Is git installed and on PATH\\?","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/util/git.rs","lineNumber":19,"sourceCode":"// Copyright 2018-2026 the Deno authors. MIT license.\n\nuse std::path::Path;\nuse std::process::Stdio;\n\nuse deno_core::anyhow::anyhow;\nuse deno_core::error::AnyError;\nuse tokio::process::Command;\n\n/// Run `git` with `args` in `cwd`, returning stdout on success.\npub fn run_git(cwd: &Path, args: &[&str]) -> Result<String, AnyError> {\n  let output = match std::process::Command::new(\"git\")\n    .current_dir(cwd)\n    .args(args)\n    .output()\n  {\n    Ok(output) => output,\n    Err(err) => {\n      return Err(anyhow!(\n        \"Failed to run `git {}`: {err}. Is git installed and on PATH?\",\n        args.join(\" \")\n      ));\n    }\n  };\n  if !output.status.success() {\n    return Err(anyhow!(\n      \"`git {}` failed: {}\",\n      args.join(\" \"),\n      String::from_utf8_lossy(&output.stderr).trim()\n    ));\n  }\n  Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n}\n\npub async fn check_if_git_repo_dirty(cwd: &Path) -> Option<String> {\n  let bin_name = if cfg!(windows) { \"git.exe\" } else { \"git\" };\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/util/git.rs#L1-L37","documentation":"run_git (cli/util/git.rs:11-24) spawns the system `git` for features such as `deno test --changed` (changed_files_from_git, cli/tools/test/mod.rs:2183). This variant fires when the spawn itself fails — overwhelmingly `git` not installed or not reachable on PATH (io ErrorKind NotFound), or a broken PATH in the calling environment.","triggerScenarios":"deno test --changed in a slim container or cron job where git is absent; PATH stripped/reset by a wrapper; git installed as a shell function or alias rather than an executable.","commonSituations":"Minimal Docker images (deno:* without git), CI stages that prune toolchain, Windows machines with Git Bash not on PATH, scheduled tasks with sanitized environments.","solutions":["Install git: apt-get install -y git / brew install git / winget install Git.Git, then verify with `git --version` in the same shell.","Fix PATH so the git binary directory is included (e.g. /usr/bin, /opt/homebrew/bin, C:\\\\Program Files\\\\Git\\\\cmd).","If git is not an option, drop the git-dependent flag (run deno test without --changed)."],"exampleFix":"# before\n$ deno test --changed\nerror: Failed to run `git rev-parse --show-toplevel`: ... Is git installed and on PATH?\n\n# after — install git in the image / environment\nRUN apt-get update && apt-get install -y git\ndeno test --changed","handlingStrategy":"validation","validationCode":"# Gate git-dependent features on git being present\ncommand -v git >/dev/null 2>&1 || { echo 'git not on PATH — skipping --changed'; exit 0; }\ndeno test --changed","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install git in the same image/environment that runs deno test --changed.","Verify `git --version` works in CI before stages that depend on it.","Make git-dependent flags conditional in scripts so machines without git degrade gracefully."],"tags":["git","path","spawn","test"],"backgroundTag":"missing-executable-on-path","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}