abhigyanpatwari/GitNexus · error · Error
Codex CLI not found. Install Codex CLI and ensure `codex` is
Error message
Codex CLI not found. Install Codex CLI and ensure `codex` is on PATH.
What it means
The wiki `--provider codex` path shells out to the local Codex CLI. detectLocalCLI runs `codex --version`; on ENOENT (not on PATH) or non-zero exit the provider is cached as unavailable and callCodexLLM throws before doing any work. The call itself uses `codex exec --sandbox read-only` writing the final message to a temp file.
Source
Thrown at gitnexus/src/core/wiki/local-cli-client.ts:127
}
const fullPrompt = systemPrompt ? `${systemPrompt}\n\n---\n\n${prompt}` : prompt;
const response = await runLocalCLI('claude', commandInfo, args, config, fullPrompt, options);
if (!response.content) {
throw new Error('claude CLI returned empty output');
}
return response;
}
export async function callCodexLLM(
prompt: string,
config: LocalCLIConfig,
systemPrompt?: string,
options?: CallLLMOptions,
): Promise<LLMResponse> {
const commandInfo = getDetectedCommand('codex');
if (!commandInfo) {
throw new Error('Codex CLI not found. Install Codex CLI and ensure `codex` is on PATH.');
}
const outputDir = await fs.mkdtemp(path.join(os.tmpdir(), 'gitnexus-wiki-codex-'));
const outputPath = path.join(outputDir, 'last-message.txt');
const workingDirectory = config.workingDirectory || process.cwd();
const fullPrompt = systemPrompt ? `${systemPrompt}\n\n---\n\n${prompt}` : prompt;
const args = [
'exec',
'--cd',
workingDirectory,
'--sandbox',
'read-only',
'-c',
'approval_policy="never"',
'--color',
'never',
'--output-last-message',
outputPath,View on GitHub (pinned to aac7515d2a)
Solutions
- Install the Codex CLI and verify `codex --version` succeeds in the same environment gitnexus runs in
- Ensure the install's bin directory is on PATH (export PATH="$PATH:$(npm bin -g)" or equivalent)
- Authenticate (`codex` login) after installing
- Or use an HTTP provider instead: `--provider openai --api-key ...`
Example fix
# before gitnexus wiki --provider codex # codex: not found # after npm install -g @openai/codex codex --version gitnexus wiki --provider codex
Defensive patterns
Strategy: validation
Validate before calling
import { execFileSync } from 'child_process';
function codexCliAvailable(): boolean {
try { execFileSync('codex', ['--version'], { stdio: 'ignore' }); return true; }
catch { return false; }
}
if (!codexCliAvailable()) throw new Error('Install Codex CLI first'); Type guard
function codexCliAvailable(): boolean {
try { execFileSync('codex', ['--version'], { stdio: 'ignore' }); return true; }
catch { return false; }
} Try / catch
try {
await callCodexLLM(prompt, config);
} catch (err) {
if (err instanceof Error && err.message.includes('Codex CLI not found')) {
return callLLM(prompt, httpConfig); // fall back to an HTTP provider
}
throw err;
} Prevention
- Pre-flight `codex --version` when selecting --provider codex
- Ensure npm global bin (or Homebrew bin) is on PATH in non-interactive shells/CI
- Document the HTTP-provider alternative for users without local CLIs
When it happens
Trigger: Running `gitnexus wiki --provider codex` without the Codex CLI installed; `codex` not on PATH in the current shell, service, or CI container; broken install where `codex --version` fails.
Common situations: CI environments without the CLI; PATH missing the install dir (npm global bin, Homebrew bin) in non-login shells; assuming `--provider codex` uses an OpenAI API key instead of the local CLI.
Related errors
- Claude CLI not found. Install Claude Code and ensure `claude
- codex CLI returned empty output
- --allow-insecure-connection / GITNEXUS_ALLOW_INSECURE_CONNEC
- Invalid LLM base URL: must be a well-formed http:// or https
- LLM base URL must use http:// or https:// (got ${parsed.prot
AI-assisted analysis of abhigyanpatwari/GitNexus@aac7515d2a (2026-08-20).
Data as JSON: /api/errors/59782b55d06fec9b.
Report an issue: GitHub.