[BUG] Background session re-claimed with `(fleet)` comes back with launchd's bare PATH, not the environment it ran with

Status Open
Reported on v2.1.285
Maintainer reply None cached
Activity 0 comments · opened Sep 30, 2026

What happens. A background session (claude --bg) settles. The daemon later revives it into a pre-started worker, and daemon.log records a bg claimed-spare <id> (fleet) claim. The revived session's shell then has PATH=/usr/bin:/bin:/usr/sbin:/sbin. The entries it was launched with are gone, so commands that resolved before the settle (gh, Homebrew tools, a PATH shim) are no longer found.

Expected. The revived session keeps the environment the job ran with, or at least the worker's own PATH, as a (spare) claim and a fresh dispatch both do.

Evidence (macOS, Claude Code background sessions launched from a GUI app that composes PATH at spawn):

  • A per-session hook recorded the PATH state. Every (fleet) re-claim observed came back bare: two sessions, three occurrences on 2026-09-29. (spare) claims and new dispatches kept the composed PATH.
  • ps -E on the daemon and on the pre-started worker both showed the composed PATH (a shim directory first, then the system entries). So the bare PATH isn't inherited from either process; it's set when the job moves into the worker.
  • The job record (~/.claude/jobs/<id>/state.json) has no env key, and providerEnv holds at most CLAUDE_CONFIG_DIR. Nothing on the launcher's side of the record could carry PATH across.
  • Restarting the daemon clears it. The next claim of the session comes back with the composed PATH.

Repro sketch.

  1. Launch claude --bg with a PATH that includes a non-system directory (e.g. /opt/homebrew/bin).
  2. Let the session settle (bg settled <id> (done)).
  3. Send it a message so the daemon revives it. Watch for (fleet) in daemon.log.
  4. Inside, run echo $PATH or command -v gh.

Environment. Claude Code 2.1.285, macOS 27.2 (Apple silicon).

View original on GitHub ↗