chenhg5/cc-connect · error

claudecode: 'claude' CLI not found in PATH

Error message

claudecode: 'claude' CLI not found in PATH

What it means

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.

Source

Thrown at agent/claudecode/claude_usage.go:51

	claudeUsageResetLineRe  = regexp.MustCompile(`(?i)^resets\s+(.+?)\s*$`)
	claudeUsageParenTZRe    = regexp.MustCompile(`^(.*?)\s*\(([^()]+)\)\s*$`)
	claudeUsageWhitespaceRe = regexp.MustCompile(`[ \t]+`)
	claudeUsageRuleLineRe   = regexp.MustCompile(`^[\p{Zs}\-─━_=]{4,}$`)
)

type claudeUsageProbeState struct {
	promptResponses int
	sentWake        bool
	sentUsage       bool
	sentEnterRetry  bool
	sentUsageRetry  bool
	lastActionAt    time.Time
	usageSentAt     time.Time
}

func (a *Agent) GetUsage(ctx context.Context) (*core.UsageReport, error) {
	if _, err := exec.LookPath("claude"); err != nil {
		return nil, fmt.Errorf("claudecode: 'claude' CLI not found in PATH")
	}

	screen, err := a.runClaudeUsageProbe(ctx)
	if err != nil {
		return nil, err
	}
	return parseClaudeUsageReport(screen, time.Now())
}

func (a *Agent) runClaudeUsageProbe(ctx context.Context) (string, error) {
	probeCtx, cancel := context.WithCancel(ctx)
	defer cancel()

	workDir, err := os.MkdirTemp("", "cc-connect-claude-usage-*")
	if err != nil {
		return "", fmt.Errorf("claudecode: create usage temp dir: %w", err)
	}
	defer os.RemoveAll(workDir)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Install the Claude Code CLI (`npm install -g @anthropic-ai/claude-code`) or verify it exists with `which claude`
  2. Extend PATH for the cc-connect service (systemd Environment= / EnvironmentFile=, launchd plist PATH) to include the directory containing claude
  3. 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)
  4. Restart the cc-connect daemon after changing its environment so the new PATH is picked up
Defensive patterns

Strategy: fallback

Validate before calling

if _, err := exec.LookPath("claude"); err != nil { return nil, fmt.Errorf("claude CLI required for usage reports: %w", err) }

Type guard

func claudeAvailable() bool { _, err := exec.LookPath("claude"); return err == nil }

Try / catch

report, err := agent.GetUsage(ctx)
if err != nil {
    if strings.Contains(err.Error(), "CLI not found in PATH") {
        log.Warn("usage report skipped: claude CLI unavailable")
        return nil // degrade gracefully
    }
    return err
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/8242f762c4a63617. Report an issue: GitHub.