{"record":{"id":"ed18415514dd41d8","repo":"ZhuLinsen/daily_stock_analysis","slug":"command-not-found","errorCode":"command_not_found","errorMessage":"Codex executable was not found","messagePattern":"Codex executable was not found","errorType":"error_code","errorClass":"CodexAppServerError","httpStatus":null,"severity":"error","filePath":"src/agent/codex_app_server_transport.py","lineNumber":1063,"sourceCode":"                    time.sleep(0.02)\n\n            if process.poll() is None or _process_group_alive(process_group_id):\n                raise CodexAppServerError(\n                    \"resource_cleanup_failed\",\n                    \"Codex App Server process group could not be reclaimed\",\n                )\n\n\ndef resolve_command(executable: str = \"codex\") -> list[str]:\n    \"\"\"Resolve the fixed App Server argv and least-privilege overrides.\"\"\"\n    if is_native_windows():\n        raise CodexAppServerError(\n            \"capability_unsupported\",\n            \"Codex App Server Agent is not supported on native Windows in this phase\",\n        )\n    resolved = shutil.which(executable)\n    if resolved is None:\n        raise CodexAppServerError(\"command_not_found\", \"Codex executable was not found\")\n    command = [resolved, \"app-server\", \"--stdio\"]\n    for override in _BASE_CONFIG_OVERRIDES:\n        command.extend([\"-c\", override])\n    return command\n\n\ndef harden_command_against_configured_mcp(\n    command: Sequence[str],\n    *,\n    timeout: float,\n    deadline: Optional[float] = None,\n    cancel_event: Optional[threading.Event] = None,\n) -> list[str]:\n    \"\"\"Discover effective MCP config keys, then disable each via transient overrides.\"\"\"\n    empty_surface = ToolSurface.empty()\n    with CodexAppServerTransport(\n        command,\n        tool_surface=empty_surface,","sourceCodeStart":1045,"sourceCodeEnd":1081,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/src/agent/codex_app_server_transport.py#L1045-L1081","documentation":"resolve_command() uses shutil.which() to locate the codex executable on PATH and raises command_not_found when it resolves to None. This is the first POSIX-side validation after the Windows check, before any '-c' overrides are appended.","triggerScenarios":"constructing the transport on a machine where the codex CLI is not installed, not on PATH for the running process's environment (service/daemon PATH differs from login shell), or the configured executable name points to nothing.","commonSituations":"Fresh machines without codex installed; Docker images missing the codex binary; systemd/launchd services with minimal PATH; virtualenvs where PATH is rewritten; typos in a configurable executable name.","solutions":["Install the codex CLI and verify with `codex --version` from the same shell/environment the app runs in","If the app runs as a service, set PATH explicitly in its unit/env or pass an absolute executable path","Pass executable='/abs/path/codex' to resolve_command()/build_hardened_command() instead of relying on PATH lookup","In containers, add the codex install step to the image build"],"exampleFix":"// before\ncommand = resolve_command()  # raises if 'codex' not on PATH\n\n// after\ncodex_path = os.environ.get(\"CODEX_BIN\") or shutil.which(\"codex\")\nif not codex_path:\n    raise RuntimeError(\"install codex CLI or set CODEX_BIN\")\ncommand = resolve_command(executable=codex_path)","handlingStrategy":"validation","validationCode":"import shutil\n\ncodex = shutil.which(\"codex\")\nif codex is None:\n    raise RuntimeError(\"codex CLI not found on PATH; install it or set CODEX_BIN\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-check shutil.which before selecting the backend","Pin absolute paths in service environments","Bake the CLI into deployment images"],"tags":["codex","app-server","path","installation"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}