openai/codex-plugin-cc · error · Error

git is not installed. Install Git and retry.

Error message

git is not installed. Install Git and retry.

What it means

Thrown by ensureGitRepository when spawning 'git' fails with error.code === 'ENOENT', meaning the git executable was not found on PATH. The function runs git with shell:false via runCommand, so Node's spawn raises ENOENT when the binary is absent; the code maps that to an install hint.

Source

Thrown at plugins/codex/scripts/lib/git.mjs:82

    }
  }
  return totalBytes;
}

function buildBranchComparison(cwd, baseRef) {
  const mergeBase = gitChecked(cwd, ["merge-base", "HEAD", baseRef]).stdout.trim();
  return {
    mergeBase,
    commitRange: `${mergeBase}..HEAD`,
    reviewRange: `${baseRef}...HEAD`
  };
}

export function ensureGitRepository(cwd) {
  const result = git(cwd, ["rev-parse", "--show-toplevel"]);
  const errorCode = result.error && "code" in result.error ? result.error.code : null;
  if (errorCode === "ENOENT") {
    throw new Error("git is not installed. Install Git and retry.");
  }
  if (result.status !== 0) {
    throw new Error("This command must run inside a Git repository.");
  }
  return result.stdout.trim();
}

export function getRepoRoot(cwd) {
  return gitChecked(cwd, ["rev-parse", "--show-toplevel"]).stdout.trim();
}

export function detectDefaultBranch(cwd) {
  const symbolic = git(cwd, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
  if (symbolic.status === 0) {
    const remoteHead = symbolic.stdout.trim();
    if (remoteHead.startsWith("refs/remotes/origin/")) {
      return remoteHead.replace("refs/remotes/origin/", "");
    }

View on GitHub (pinned to db52e28f4d)

Solutions

  1. Install Git (apt-get install git, brew install git, or the official Windows installer).
  2. Ensure the git executable directory is on PATH for the process running the agent.
  3. On Windows, confirm 'git --version' works in the same shell; add Git's bin to PATH.
  4. Restart the shell/agent after PATH changes so the new environment is picked up.

Example fix

// before
ensureGitRepository(cwd) // throws ENOENT -> 'git is not installed'

// after (shell setup)
//   apt-get update && apt-get install -y git   # Linux
//   brew install git                           # macOS
//   # Windows: install Git for Windows, ensure C:\Program Files\Git\cmd on PATH
ensureGitRepository(cwd)
Defensive patterns

Strategy: validation

Validate before calling

import { execFileSync } from 'node:child_process';

function gitAvailable() {
  try {
    execFileSync('git', ['--version'], { stdio: 'ignore', shell: false });
    return true;
  } catch {
    return false;
  }
}
if (!gitAvailable()) {
  throw new Error('Git must be installed and on PATH');
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Calling ensureGitRepository(cwd) (directly or via resolveReviewTarget) on a system where git is not installed or not on the process PATH. The ENOENT comes from Node's child_process.spawn failing to locate the 'git' executable.

Common situations: Minimal container/CI image without git. A desktop where git is installed but PATH is not propagated to the agent's process. Windows without Git on PATH (or git.cmd not resolvable). A sandboxed environment that strips PATH.

Related errors


AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13). Data as JSON: /api/errors/de2864fa0ff5aef1. Report an issue: GitHub.