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
- Install Git (apt-get install git, brew install git, or the official Windows installer).
- Ensure the git executable directory is on PATH for the process running the agent.
- On Windows, confirm 'git --version' works in the same shell; add Git's bin to PATH.
- 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
- Install Git in all environments that run repo-relative commands (CI, containers).
- Ensure the git bin dir is on PATH for the agent process.
- On Windows, install Git for Windows and add its cmd dir to PATH.
- Probe 'git --version' during onboarding/setup.
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
- Codex CLI is not installed or is missing required runtime su
- Codex CLI is not installed or is missing required runtime su
- This command must run inside a Git repository.
- Unable to detect the repository default branch. Pass --base
AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13).
Data as JSON: /api/errors/de2864fa0ff5aef1.
Report an issue: GitHub.