chenhg5/cc-connect · error
claudecode: start claude usage probe: %w
Error message
claudecode: start claude usage probe: %w
What it means
runClaudeUsageProbe starts the claude CLI under a PTY (pty.StartWithSize, 40x120) so it behaves like an interactive session for the usage probe. This error wraps the pty start failure — the command could not be spawned or a PTY could not be allocated (e.g. the claude binary missing from the probe's working context, exec format issues, or OS pty exhaustion).
Source
Thrown at agent/claudecode/claude_usage.go:92
"--no-chrome",
}
cmd := exec.CommandContext(probeCtx, "claude", args...)
cmd.Dir = workDir
env := filterEnv(os.Environ(), "CLAUDECODE")
env = append(env, "DISABLE_TELEMETRY=true")
env = append(env, "DISABLE_COST_WARNINGS=true")
if extra := a.usageProbeEnv(); len(extra) > 0 {
env = core.MergeEnv(env, extra)
}
cmd.Env = env
var stderr bytes.Buffer
cmd.Stderr = &stderr
ptmx, err := pty.StartWithSize(cmd, &pty.Winsize{Rows: 40, Cols: 120})
if err != nil {
return "", fmt.Errorf("claudecode: start claude usage probe: %w", err)
}
var waitErr error
processDone := make(chan struct{})
go func() {
waitErr = cmd.Wait()
close(processDone)
}()
terminal := newClaudeUsageTerminal()
readDone := make(chan error, 1)
go func() {
buf := make([]byte, 4096)
for {
n, err := ptmx.Read(buf)
if n > 0 {
terminal.Write(buf[:n])
}View on GitHub (pinned to 4000b2338a)
Solutions
- Confirm `claude` is still executable (`claude --version`) and that PATH is stable for the daemon
- Check the wrapped error's cause: 'no such file' → reinstall claude; 'operation not permitted' → PTY restrictions in container/sandbox
- Raise ulimit -n / process limits if fd or pty exhaustion is reported
- Ensure the probe's working directory exists and is accessible by the service user, then retry GetUsage
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := exec.LookPath("claude"); err != nil { return err }
if err := unix.Access(claudePath, unix.X_OK); err != nil { return fmt.Errorf("claude not executable: %w", err) } Try / catch
screen, err := runClaudeUsageProbe(ctx)
if err != nil {
if strings.Contains(err.Error(), "start claude usage probe") {
log.Errorf("PTY spawn failed: %v (check pty permissions, fd limits, container seccomp)", err)
return nil // or fall back to non-PTY execution
}
return err
} Prevention
- Grant the daemon's container/sandbox permission to allocate PTYs (/dev/ptmx, devpts mount)
- Raise nofile/process ulimits for long-running daemons
- Verify `claude --version` works as the service user after every CLI update
- Provide a non-PTY fallback path for environments where pty.StartWithSize is unavailable
When it happens
Trigger: GetUsage → runClaudeUsageProbe builds the claude command (--tools "" --permission-mode plan ...) and calls pty.StartWithSize(cmd, &pty.Winsize{...}); error occurs when cmd.Path cannot be resolved/executed, the working dir is invalid, the OS denies pty allocation, or out of pty/file descriptors.
Common situations: claude binary was removed between the LookPath check and spawn; running inside a container/runtime that disallows PTY allocation; ulimit on processes/file descriptors exhausted; cwd options point at a deleted directory.
Related errors
- hook exec: %w (stderr: %s)
- acp: probe start %s: %w
- antigravitySession: start: %w
- codex app-server start: %w
- codex app-server exited: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/8536e182b652fdf3.
Report an issue: GitHub.