Graphify-Labs/graphify · error · RuntimeError
Claude Code CLI not found on $PATH
Error message
Claude Code CLI not found on $PATH
What it means
RuntimeError raised by the claude-cli backend when `shutil.which("claude")` finds no executable on PATH on a non-Windows system (or on Windows when neither claude.cmd nor claude resolves). graphify invokes the Claude Code CLI as a subprocess (`claude -p --output-format json`), so it hard-fails up front if the binary is missing rather than failing mid-pipeline.
Source
Thrown at graphify/llm.py:2618
messages=[{"role": "user", "content": prompt}],
)
u = getattr(resp, "usage", None)
if u is not None:
_rec(getattr(u, "input_tokens", 0), getattr(u, "output_tokens", 0))
return resp.content[0].text if resp.content else ""
if backend == "claude-cli":
import platform, shutil, subprocess
# Mirror the extraction-path resolution: on Windows the npm shim is
# claude.cmd, which CreateProcess can't resolve from a bare "claude"
# (PATHEXT doesn't apply), so pass the resolved .cmd path explicitly.
claude_cmd = "claude"
if platform.system() == "Windows":
cmd_path = shutil.which("claude.cmd")
if cmd_path:
claude_cmd = cmd_path
elif shutil.which("claude") is None:
raise RuntimeError("Claude Code CLI not found on $PATH")
elif shutil.which("claude") is None:
raise RuntimeError("Claude Code CLI not found on $PATH")
cli_args = [claude_cmd, "-p", "--output-format", "json", "--no-session-persistence"]
if model is not None:
cli_args.extend(["--model", mdl])
proc = subprocess.run(
cli_args,
input=prompt,
capture_output=True,
text=True,
encoding="utf-8", # Force UTF-8 — prevents UnicodeEncodeError on Windows cp1252
errors="replace", # Tolerate non-UTF-8 bytes (e.g. GBK/cp936 from claude.cmd on Chinese Windows)
timeout=_resolve_api_timeout(),
check=False,
**_no_window_kwargs(),
)
cli_error = _claude_cli_error(proc.stdout)
if proc.returncode != 0:View on GitHub (pinned to 7fe58b0b0f)
Solutions
- Verify the CLI exists: `which claude` - if empty, install with `npm install -g @anthropic-ai/claude-code`.
- If it is installed but not found, add its directory to PATH (e.g. `export PATH="$HOME/.npm-global/bin:$PATH"` or the nvm bin dir) in the exact shell/service env that runs graphify.
- If you cannot install the CLI, switch the backend to 'claude' (anthropic package) or another provider.
Example fix
# before: backend shells out to a missing binary $ graphify update . --backend claude-cli # RuntimeError: Claude Code CLI not found on $PATH # after: install the CLI globally, then re-run $ npm install -g @anthropic-ai/claude-code $ which claude && graphify update . --backend claude-cli
Defensive patterns
Strategy: validation
Validate before calling
import shutil, platform
def claude_cli_available() -> bool:
if platform.system() == "Windows":
return shutil.which("claude.cmd") is not None or shutil.which("claude") is not None
return shutil.which("claude") is not None
if not claude_cli_available():
raise SystemExit("Install Claude Code CLI: npm install -g @anthropic-ai/claude-code") Try / catch
try:
result = call_llm(prompt, backend="claude-cli")
except RuntimeError as exc:
if "CLI not found" in str(exc):
raise SystemExit("claude CLI missing from PATH - install or fix PATH") from exc
raise Prevention
- For service/cron environments, print PATH and `which claude` in a healthcheck before long jobs.
- Prefer absolute paths in config if the CLI location is stable (e.g. /usr/local/bin/claude).
- Remember Windows uses claude.cmd - the same check must consider PATHEXT shims.
When it happens
Trigger: Selecting backend 'claude-cli' on Linux/macOS while `claude` is not on $PATH: graphify/llm.py:2617-2620 runs shutil.which and raises when it returns None. Happens for any LLM call (labels, dedup, extraction) once that backend is chosen.
Common situations: Node/npm installed the CLI under a user npm prefix (e.g. ~/.npm-global/bin) that is not on PATH in cron, CI, or a service context; nvm-managed node where the shell that installed claude differs from the one running graphify; the user installed the desktop app but never `npm install -g @anthropic-ai/claude-code`.
Related errors
- graph not found: {source_path}
- No git repository found at or above {path.resolve()}
- Claude Code CLI not found on $PATH. Install from https://cla
- Azure OpenAI backend requires AZURE_OPENAI_ENDPOINT to be se
- gh CLI not found or not authenticated. Run: gh auth login
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/a61b1295fface3e9.
Report an issue: GitHub.