Shell snapshot PATH export contains only the plugin bin dir, system directories lost (2.1.204)

Status Open
Reported on v2.1.204
Maintainer reply None cached
Activity 0 comments · opened Jul 26, 2026

Bug Description

When a plugin is enabled, the last line of the generated shell snapshot sets PATH to only the plugin's bin directory, discarding everything inherited from the user's shell profile. Every bare command in the Bash tool then fails with "command not found", including cat, cp, head, git, python3, and node.

This appears to be the same defect family as #31799 and #38951 (both closed as inactive, both locked, both inviting a fresh issue). In those reports the snapshot contained a literal unexpanded $PATH. Here the $PATH segment is absent entirely, so the plugin bin path becomes the whole value. Filing fresh as instructed by the lock messages.

Environment

  • Claude Code version: 2.1.204 (build 2026-07-07)
  • OS: macOS, Darwin 25.5.0, arm64
  • Shell: zsh
  • Terminal: Warp
  • Install: npm global via nvm, running under bun
  • Auth: claude.ai subscription
  • Plugin enabled: security-guidance@claude-plugins-official 2.0.6

Observed Behavior

Last line of ~/.claude/shell-snapshots/snapshot-zsh-*.sh:

export PATH=/Users/<user>/.claude/plugins/cache/claude-plugins-official/security-guidance/2.0.6/bin

Inside the Bash tool:

$ echo $PATH
/Users/<user>/.claude/plugins/cache/claude-plugins-official/security-guidance/2.0.6/bin

$ cat somefile
zsh: command not found: cat

A login shell is unaffected and shows the correct value, with the plugin dir appended last:

$ /bin/zsh -lc 'echo $PATH'
/opt/homebrew/bin:/opt/homebrew/sbin:...:/usr/bin:/bin:/usr/sbin:/sbin:/Users/<user>/.claude/plugins/cache/.../bin

So the profile is read correctly; the snapshot's final export PATH= is what discards it. Because that line executes after the profile has loaded, it wins.

Worth noting: security-guidance 2.0.6 ships no bin/ directory at all. The path added as the sole PATH entry does not exist on disk.

Expected Behavior

Plugin bin directories should be prepended or appended to the existing PATH, not replace it. If a plugin has no bin/ directory, no entry should be added.

Steps to Reproduce

  1. Enable any plugin, e.g. security-guidance@claude-plugins-official.
  2. Do not set env.PATH in settings.json.
  3. Start a session and run echo $PATH through the Bash tool.
  4. Observe that only the plugin bin path is present, and that cat, cp, head etc. fail.

Workaround

Setting env.PATH explicitly in ~/.claude/settings.json fixes it. The snapshot then writes <env.PATH>:<plugin bin>, which is the correct shape:

{
  "env": {
    "PATH": "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
  }
}

This suggests the composition is roughly ${env.PATH}:${pluginBins}, where an unset env.PATH yields an empty base instead of falling back to the inherited or profile PATH.

Impact

Beyond the immediate failures, agents silently work around it: scanning 50 recent session transcripts on this machine turned up 113 commands containing export PATH=, i.e. the model repeatedly re-establishing a usable PATH before doing real work. Each failed call and each workaround consumes tokens and rate limit, and the root cause is easy to misattribute to the user's shell configuration.

View original on GitHub ↗