{"record":{"id":"421c4b0052e35c46","repo":"openai/codex-plugin-cc","slug":"codex-cli-is-not-installed-or-is-missing-required","errorCode":null,"errorMessage":"Codex CLI is not installed or is missing required runtime support. Install it with `npm install -g @openai/codex`, then rerun `/codex:setup`.","messagePattern":"Codex CLI is not installed or is missing required runtime support\\. Install it with `npm install -g @openai/codex`, then rerun `/codex:setup`\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/codex-companion.mjs","lineNumber":255,"sourceCode":"  const finalReport = await buildSetupReport(cwd, actionsTaken);\n  outputResult(options.json ? finalReport : renderSetupReport(finalReport), options.json);\n}\n\nfunction buildAdversarialReviewPrompt(context, focusText) {\n  const template = loadPromptTemplate(ROOT_DIR, \"adversarial-review\");\n  return interpolateTemplate(template, {\n    REVIEW_KIND: \"Adversarial Review\",\n    TARGET_LABEL: context.target.label,\n    USER_FOCUS: focusText || \"No extra focus provided.\",\n    REVIEW_COLLECTION_GUIDANCE: context.collectionGuidance,\n    REVIEW_INPUT: context.content\n  });\n}\n\nfunction ensureCodexAvailable(cwd) {\n  const availability = getCodexAvailability(cwd);\n  if (!availability.available) {\n    throw new Error(\"Codex CLI is not installed or is missing required runtime support. Install it with `npm install -g @openai/codex`, then rerun `/codex:setup`.\");\n  }\n}\n\nfunction buildNativeReviewTarget(target) {\n  if (target.mode === \"working-tree\") {\n    return { type: \"uncommittedChanges\" };\n  }\n\n  if (target.mode === \"branch\") {\n    return { type: \"baseBranch\", branch: target.baseRef };\n  }\n\n  return null;\n}\n\nfunction validateNativeReviewRequest(target, focusText) {\n  if (focusText.trim()) {\n    throw new Error(","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/codex-companion.mjs#L237-L273","documentation":"ensureCodexAvailable calls getCodexAvailability(cwd) which probes for the `codex` binary and required runtime support. If unavailable, every task/review command aborts here because they all need to spawn or connect to `codex app-server`. The message directs the user to install globally and rerun setup.","triggerScenarios":"First run on a machine without @openai/codex installed, after a global uninstall, when codex is installed but the PATH in the agent's env does not include the npm global bin, or when the codex binary exists but fails its runtime support probe (e.g. incompatible node/native deps).","commonSituations":"Fresh CI environment, container without codex baked in, or a node version mismatch where codex launches but its native module check fails.","solutions":["Run: npm install -g @openai/codex","Verify `codex --version` works in the SAME shell/env the companion runs in (check PATH includes npm global bin).","Rerun /codex:setup to confirm getCodexAvailability now reports available.","If installed but unavailable, check node version and native dependencies required by codex."],"exampleFix":"// before (codex missing)\ncodex-companion.mjs task \"do work\"\n// after\nnpm install -g @openai/codex && codex-companion.mjs task \"do work\"","handlingStrategy":"validation","validationCode":"const avail = getCodexAvailability(cwd);\nif (!avail.available) {\n  throw new Error('codex unavailable: ' + JSON.stringify(avail));\n}","typeGuard":"/** @returns {boolean} */\nfunction isCodexReady(cwd) { return getCodexAvailability(cwd).available; }","tryCatchPattern":null,"preventionTips":["Run /codex:setup in CI before any task/review command.","Pin codex version in the environment to avoid surprise breakage."],"tags":["environment","dependency","codex","setup"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}