{"record":{"id":"59782b55d06fec9b","repo":"abhigyanpatwari/GitNexus","slug":"codex-cli-not-found-install-codex-cli-and-ensure","errorCode":null,"errorMessage":"Codex CLI not found. Install Codex CLI and ensure `codex` is on PATH.","messagePattern":"Codex CLI not found\\. Install Codex CLI and ensure `codex` is on PATH\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/wiki/local-cli-client.ts","lineNumber":127,"sourceCode":"  }\n  const fullPrompt = systemPrompt ? `${systemPrompt}\\n\\n---\\n\\n${prompt}` : prompt;\n\n  const response = await runLocalCLI('claude', commandInfo, args, config, fullPrompt, options);\n  if (!response.content) {\n    throw new Error('claude CLI returned empty output');\n  }\n  return response;\n}\n\nexport async function callCodexLLM(\n  prompt: string,\n  config: LocalCLIConfig,\n  systemPrompt?: string,\n  options?: CallLLMOptions,\n): Promise<LLMResponse> {\n  const commandInfo = getDetectedCommand('codex');\n  if (!commandInfo) {\n    throw new Error('Codex CLI not found. Install Codex CLI and ensure `codex` is on PATH.');\n  }\n\n  const outputDir = await fs.mkdtemp(path.join(os.tmpdir(), 'gitnexus-wiki-codex-'));\n  const outputPath = path.join(outputDir, 'last-message.txt');\n  const workingDirectory = config.workingDirectory || process.cwd();\n  const fullPrompt = systemPrompt ? `${systemPrompt}\\n\\n---\\n\\n${prompt}` : prompt;\n  const args = [\n    'exec',\n    '--cd',\n    workingDirectory,\n    '--sandbox',\n    'read-only',\n    '-c',\n    'approval_policy=\"never\"',\n    '--color',\n    'never',\n    '--output-last-message',\n    outputPath,","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/wiki/local-cli-client.ts#L109-L145","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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 ...`"],"exampleFix":"# before\ngitnexus wiki --provider codex   # codex: not found\n\n# after\nnpm install -g @openai/codex\ncodex --version\ngitnexus wiki --provider codex","handlingStrategy":"validation","validationCode":"import { execFileSync } from 'child_process';\nfunction codexCliAvailable(): boolean {\n  try { execFileSync('codex', ['--version'], { stdio: 'ignore' }); return true; }\n  catch { return false; }\n}\nif (!codexCliAvailable()) throw new Error('Install Codex CLI first');","typeGuard":"function codexCliAvailable(): boolean {\n  try { execFileSync('codex', ['--version'], { stdio: 'ignore' }); return true; }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  await callCodexLLM(prompt, config);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Codex CLI not found')) {\n    return callLLM(prompt, httpConfig); // fall back to an HTTP provider\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["llm","codex-cli","cli-not-found","path","gitnexus"],"backgroundTag":"cli-not-found","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}