{"record":{"id":"5e0f438b8ae99db1","repo":"NousResearch/hermes-agent","slug":"the-claude-cli-is-not-installed-install-it-with","errorCode":null,"errorMessage":"The 'claude' CLI is not installed. Install it with: npm install -g @anthropic-ai/claude-code","messagePattern":"The 'claude' CLI is not installed\\. Install it with: npm install -g @anthropic-ai/claude-code","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"agent/anthropic_adapter.py","lineNumber":1460,"sourceCode":"    return None\n\n\ndef run_oauth_setup_token() -> Optional[str]:\n    \"\"\"Run 'claude setup-token' interactively and return the resulting token.\n\n    Checks multiple sources after the subprocess completes:\n      1. Claude Code credential files (may be written by the subprocess)\n      2. CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_TOKEN env vars\n\n    Returns the token string, or None if no credentials were obtained.\n    Raises FileNotFoundError if the 'claude' CLI is not installed.\n    \"\"\"\n    import shutil\n    import subprocess\n\n    claude_path = shutil.which(\"claude\")\n    if not claude_path:\n        raise FileNotFoundError(\n            \"The 'claude' CLI is not installed. \"\n            \"Install it with: npm install -g @anthropic-ai/claude-code\"\n        )\n\n    # Run interactively — stdin/stdout/stderr inherited so the user can\n    # complete the OAuth login prompt. Must keep inherited stdin; the TUI-EOF\n    # concern does not apply to an interactive login the user explicitly\n    # invokes.  noqa: subprocess-stdin\n    try:\n        subprocess.run([claude_path, \"setup-token\"])\n    except (KeyboardInterrupt, EOFError):\n        return None\n\n    # Check if credentials were saved to Claude Code's config files\n    creds = read_claude_code_credentials()\n    if creds and is_claude_code_token_valid(creds):\n        return creds[\"accessToken\"]\n","sourceCodeStart":1442,"sourceCodeEnd":1478,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/anthropic_adapter.py#L1442-L1478","documentation":"FileNotFoundError raised when starting the interactive Claude Code OAuth login: shutil.which('claude') found no claude executable on PATH. The flow shells out to the claude CLI's setup-token command with inherited stdio so the user can complete the browser login, so the binary is a hard prerequisite.","triggerScenarios":"Invoking the claude-setup-token login flow on a machine without the @anthropic-ai/claude-code npm package installed, or where the claude binary's directory is not on the current PATH.","commonSituations":"Fresh machine; nvm/npm global bin directory missing from PATH in this shell; claude installed under a different node version manager; headless server where npm globals were never installed.","solutions":["npm install -g @anthropic-ai/claude-code","If already installed, ensure the npm global bin dir is on PATH and reopen the shell","Alternatively skip the CLI flow and provide the token directly via CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_TOKEN env vars"],"exampleFix":"# before: FileNotFoundError('The \\'claude\\' CLI is not installed')\n# after\nnpm install -g @anthropic-ai/claude-code\nclaude setup-token","handlingStrategy":"validation","validationCode":"import shutil\n\ndef claude_cli_present() -> bool:\n    return shutil.which(\"claude\") is not None\n\n# before launching interactive login:\nif not claude_cli_present():\n    instruct_user(\"npm install -g @anthropic-ai/claude-code\")\n    return","typeGuard":null,"tryCatchPattern":"try:\n    token = run_claude_setup_token()\nexcept FileNotFoundError as e:\n    if \"claude\" in str(e):\n        print(str(e))  # contains the npm install instruction\n        return None","preventionTips":["Install the claude CLI before invoking OAuth login flows that shell out to it","Ensure the npm global bin directory is on PATH in the shell that runs hermes","For headless hosts, prefer CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_TOKEN env vars over the CLI flow"],"tags":["anthropic","oauth","cli","dependency"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}