{"record":{"id":"c289d75b9fd2a91f","repo":"Graphify-Labs/graphify","slug":"claude-code-cli-not-found-on-path-install-from-h","errorCode":null,"errorMessage":"Claude Code CLI not found on $PATH. Install from https://claude.ai/code and run `claude` once to authenticate.","messagePattern":"Claude Code CLI not found on \\$PATH\\. Install from https://claude\\.ai/code and run `claude` once to authenticate\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"graphify/llm.py","lineNumber":1492,"sourceCode":"    is allowlisted with `--add-dir` so the read is permitted.\n    \"\"\"\n    import platform\n    import shutil\n    import subprocess\n\n    # On Windows, npm installs `claude` as both `claude.ps1` and `claude.cmd`\n    # alongside each other. When PATHEXT lists `.PS1` before `.CMD`,\n    # `shutil.which(\"claude\")` returns `claude.ps1`, which `CreateProcess`\n    # cannot execute directly — it raises `[WinError 2] The system cannot\n    # find the file specified`. `claude.cmd` IS executable by CreateProcess,\n    # so prefer it explicitly on Windows. See issue #1072.\n    claude_cmd = \"claude\"\n    if platform.system() == \"Windows\":\n        cmd_path = shutil.which(\"claude.cmd\")\n        if cmd_path:\n            claude_cmd = cmd_path\n        elif shutil.which(\"claude\") is None:\n            raise RuntimeError(\n                \"Claude Code CLI not found on $PATH. Install from \"\n                \"https://claude.ai/code and run `claude` once to authenticate.\"\n            )\n    elif shutil.which(\"claude\") is None:\n        raise RuntimeError(\n            \"Claude Code CLI not found on $PATH. Install from \"\n            \"https://claude.ai/code and run `claude` once to authenticate.\"\n        )\n\n    # Deliver the extraction instructions in the USER turn rather than via\n    # --system-prompt. Newer Claude Code CLIs (>= ~2.1) do not treat a\n    # --system-prompt as the sole authority: they still layer in the local\n    # coding-agent context (CLAUDE.md/AGENTS.md in cwd, skills, MCP) and, when\n    # the user turn is only a raw file dump with no request, reply\n    # conversationally (\"I see the file, but there's no actual request\n    # attached — what would you like me to do with it?\"). That prose parses to\n    # zero nodes/edges, so _response_is_hollow flags it as truncation and the\n    # adaptive-retry path bisects the chunk indefinitely, never converging and","sourceCodeStart":1474,"sourceCodeEnd":1510,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/llm.py#L1474-L1510","documentation":"Raised on non-Windows platforms (and on Windows when neither `claude.cmd` nor plain `claude` resolves) when `shutil.which(\"claude\")` returns None — the Claude Code CLI executable is not on $PATH. The `claude-cli` backend shells out to this binary, so it must be installed and locatable before extraction can run. On Windows the code first prefers `claude.cmd` over `claude.ps1` because CreateProcess cannot execute .ps1 files (issue #1072).","triggerScenarios":"Calling `extract_files_direct(..., backend=\"claude-cli\")` on Linux/macOS where `shutil.which(\"claude\")` is None; or on Windows where both `claude.cmd` and `claude` are absent.","commonSituations":"Claude Code CLI never installed; installed via npm but npm's global bin directory is not on $PATH for the shell/process running graphify; running graphify from a service/container/cron environment with a minimal PATH; Windows npm stub issue (#1072).","solutions":["Install Claude Code CLI from https://claude.ai/code and run `claude` once interactively to authenticate.","Ensure the install location is on $PATH for the exact process invoking graphify: `which claude` (or `where claude` on Windows) must succeed; for npm installs add the npm global bin dir.","In containers/services, set PATH explicitly or symlink the binary into a standard directory like /usr/local/bin.","On Windows, if only claude.ps1 exists, reinstall via npm so claude.cmd is generated, since .ps1 cannot be spawned by CreateProcess."],"exampleFix":"# before (claude installed but not on service PATH)\nENV PATH=/app/bin\n\n# after\nENV PATH=/app/bin:/usr/local/bin   # npm i -g @anthropic-ai/claude-code installs into /usr/local/bin","handlingStrategy":"validation","validationCode":"import shutil\n\nif shutil.which(\"claude\") is None:\n    raise SystemExit(\"Claude Code CLI missing — install from https://claude.ai/code and re-run\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a `shutil.which(\"claude\")` preflight in scripts that use backend=\"claude-cli\".","In Dockerfiles, install the CLI and keep npm's global bin on PATH.","In services/cron, set PATH explicitly to include the CLI's install directory."],"tags":["claude-cli","path","installation","subprocess","environment"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}