{"record":{"id":"8242f762c4a63617","repo":"chenhg5/cc-connect","slug":"claudecode-claude-cli-not-found-in-path","errorCode":null,"errorMessage":"claudecode: 'claude' CLI not found in PATH","messagePattern":"claudecode: 'claude' CLI not found in PATH","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/claudecode/claude_usage.go","lineNumber":51,"sourceCode":"\tclaudeUsageResetLineRe  = regexp.MustCompile(`(?i)^resets\\s+(.+?)\\s*$`)\n\tclaudeUsageParenTZRe    = regexp.MustCompile(`^(.*?)\\s*\\(([^()]+)\\)\\s*$`)\n\tclaudeUsageWhitespaceRe = regexp.MustCompile(`[ \\t]+`)\n\tclaudeUsageRuleLineRe   = regexp.MustCompile(`^[\\p{Zs}\\-─━_=]{4,}$`)\n)\n\ntype claudeUsageProbeState struct {\n\tpromptResponses int\n\tsentWake        bool\n\tsentUsage       bool\n\tsentEnterRetry  bool\n\tsentUsageRetry  bool\n\tlastActionAt    time.Time\n\tusageSentAt     time.Time\n}\n\nfunc (a *Agent) GetUsage(ctx context.Context) (*core.UsageReport, error) {\n\tif _, err := exec.LookPath(\"claude\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"claudecode: 'claude' CLI not found in PATH\")\n\t}\n\n\tscreen, err := a.runClaudeUsageProbe(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn parseClaudeUsageReport(screen, time.Now())\n}\n\nfunc (a *Agent) runClaudeUsageProbe(ctx context.Context) (string, error) {\n\tprobeCtx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\n\tworkDir, err := os.MkdirTemp(\"\", \"cc-connect-claude-usage-*\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"claudecode: create usage temp dir: %w\", err)\n\t}\n\tdefer os.RemoveAll(workDir)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/claudecode/claude_usage.go#L33-L69","documentation":"GetUsage in agent/claudecode/claude_usage.go produces a usage report by shelling out to the Claude CLI. Before doing anything it calls exec.LookPath(\"claude\") and returns this fixed message when the binary cannot be found, telling the user the claude CLI is not installed or not on PATH for the cc-connect process.","triggerScenarios":"GetUsage → exec.LookPath(\"claude\") returns exec.ErrNotFound when no `claude` executable exists in any PATH directory of the cc-connect process environment (e.g. usage report triggered on a machine where only the agent SDK is present, or PATH differs under systemd/launchd).","commonSituations":"cc-connect runs as a daemon whose PATH lacks ~/.local/bin or npm global bin where claude was installed; claude is installed in a user shell but not in the service environment; claude was never installed on this host.","solutions":["Install the Claude Code CLI (`npm install -g @anthropic-ai/claude-code`) or verify it exists with `which claude`","Extend PATH for the cc-connect service (systemd Environment= / EnvironmentFile=, launchd plist PATH) to include the directory containing claude","Set the full path via the daemon config if supported, or symlink claude into a directory already on the service PATH (e.g. /usr/local/bin)","Restart the cc-connect daemon after changing its environment so the new PATH is picked up"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if _, err := exec.LookPath(\"claude\"); err != nil { return nil, fmt.Errorf(\"claude CLI required for usage reports: %w\", err) }","typeGuard":"func claudeAvailable() bool { _, err := exec.LookPath(\"claude\"); return err == nil }","tryCatchPattern":"report, err := agent.GetUsage(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"CLI not found in PATH\") {\n        log.Warn(\"usage report skipped: claude CLI unavailable\")\n        return nil // degrade gracefully\n    }\n    return err\n}","preventionTips":["Install Claude Code CLI on every host running cc-connect","Include the claude install dir (~/.local/bin, npm global bin) in the daemon's PATH via systemd EnvironmentFile or launchd plist","Add a startup health check (exec.LookPath(\"claude\")) that logs at boot","Run `cc-connect doctor` to catch missing CLIs before usage reports fail"],"tags":["cli","path","dependency"],"backgroundTag":"command-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}