NousResearch/hermes-agent · error · FileNotFoundError

The 'claude' CLI is not installed. Install it with: npm inst

Error message

The 'claude' CLI is not installed. Install it with: npm install -g @anthropic-ai/claude-code

What it means

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.

Source

Thrown at agent/anthropic_adapter.py:1460

    return None


def run_oauth_setup_token() -> Optional[str]:
    """Run 'claude setup-token' interactively and return the resulting token.

    Checks multiple sources after the subprocess completes:
      1. Claude Code credential files (may be written by the subprocess)
      2. CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_TOKEN env vars

    Returns the token string, or None if no credentials were obtained.
    Raises FileNotFoundError if the 'claude' CLI is not installed.
    """
    import shutil
    import subprocess

    claude_path = shutil.which("claude")
    if not claude_path:
        raise FileNotFoundError(
            "The 'claude' CLI is not installed. "
            "Install it with: npm install -g @anthropic-ai/claude-code"
        )

    # Run interactively — stdin/stdout/stderr inherited so the user can
    # complete the OAuth login prompt. Must keep inherited stdin; the TUI-EOF
    # concern does not apply to an interactive login the user explicitly
    # invokes.  noqa: subprocess-stdin
    try:
        subprocess.run([claude_path, "setup-token"])
    except (KeyboardInterrupt, EOFError):
        return None

    # Check if credentials were saved to Claude Code's config files
    creds = read_claude_code_credentials()
    if creds and is_claude_code_token_valid(creds):
        return creds["accessToken"]

View on GitHub (pinned to c896c09c42)

Solutions

  1. npm install -g @anthropic-ai/claude-code
  2. If already installed, ensure the npm global bin dir is on PATH and reopen the shell
  3. Alternatively skip the CLI flow and provide the token directly via CLAUDE_CODE_OAUTH_TOKEN / ANTHROPIC_TOKEN env vars

Example fix

# before: FileNotFoundError('The \'claude\' CLI is not installed')
# after
npm install -g @anthropic-ai/claude-code
claude setup-token
Defensive patterns

Strategy: validation

Validate before calling

import shutil

def claude_cli_present() -> bool:
    return shutil.which("claude") is not None

# before launching interactive login:
if not claude_cli_present():
    instruct_user("npm install -g @anthropic-ai/claude-code")
    return

Try / catch

try:
    token = run_claude_setup_token()
except FileNotFoundError as e:
    if "claude" in str(e):
        print(str(e))  # contains the npm install instruction
        return None

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14). Data as JSON: /api/errors/5e0f438b8ae99db1. Report an issue: GitHub.