{"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/89f33cbef296a2b287f323d42de54c871fa69c77/cli/util/git.rs#L1-L37","documentation":"Runs `git <args>` via `std::process::Command` in the given cwd. If the process cannot be spawned at all — git not installed, not on PATH, or an exec-bit problem — the io error is wrapped together with the exact git command and a PATH hint.","triggerScenarios":"Any deno feature that shells out to git (for example repository-cleanliness checks) on a machine where the `git` binary is missing or PATH omits its directory.","commonSituations":"Minimal container images (distroless, slim) without git; CI images where git exists only in the build stage; systemd units, cron, or sanitized environments with a stripped PATH.","solutions":["Install git and verify it resolves in the same shell deno runs under: `git --version` (apt-get install git / apk add git / xcode-select --install)","Fix PATH for the deno process — service units, cron entries, and containers often need it set explicitly","If git is intentionally absent in the environment, avoid the code path that requires it"],"exampleFix":"# before: distroless-style container without git\ndeno release   # -> Failed to run `git ...`\n# after (Dockerfile)\nRUN apt-get update && apt-get install -y git\nENV PATH=\"/usr/bin:${PATH}\"","handlingStrategy":"validation","validationCode":"# bash: assert git is reachable before running git-dependent deno commands\ncommand -v git >/dev/null 2>&1 || { echo \"git required but not on PATH\" >&2; exit 1; }\ndeno release","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install git in runtime images, not only build stages","Set PATH explicitly in systemd/cron/container definitions that run deno","Add a `git --version` smoke check to CI before git-dependent steps"],"tags":["git","environment","process","path"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}