Shell snapshot overwrites env.PATH from settings.json

Resolved 💬 4 comments Opened Apr 4, 2026 by Nitewriter Closed Apr 7, 2026

Bug

The env.PATH setting in ~/.claude/settings.json is correctly applied to the environment, but then overwritten by the shell snapshot's hardcoded export PATH=... line. This means PATH-dependent tools (homebrew, nix-darwin managed tools, etc.) are unavailable in the Bash tool.

Environment

  • Platform: macOS (Apple Silicon), Claude Desktop app (Code tab)
  • Shell: zsh managed by nix-darwin + home-manager
  • Homebrew: installed at /opt/homebrew/bin
  • home-manager sets PATH via home.sessionPath → generates export in hm-session-vars.sh sourced from .zshenv

Reproduction

  1. Add env.PATH to ~/.claude/settings.json:
{
  "env": {
    "PATH": "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
  }
}
  1. Delete shell snapshots: rm ~/.claude/shell-snapshots/snapshot-*.sh
  1. Restart Claude Desktop
  1. In a session, run: echo $PATH
  • Expected: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • Actual: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Root Cause

The shell snapshot (e.g. ~/.claude/shell-snapshots/snapshot-zsh-*.sh) contains a hardcoded export PATH=/usr/bin\:/bin\:/usr/sbin\:/sbin\:/usr/local/bin on its last line. This is sourced after env vars from settings.json are applied, overwriting env.PATH.

Proof that env works for other vars: Setting "JAMDOG_ENV_TEST": "working" in env is correctly visible in the Bash tool. Only PATH is affected because the snapshot explicitly overwrites it.

Proof that removing the snapshot PATH line fixes it: Commenting out the export PATH= line in the snapshot file immediately makes env.PATH work correctly.

Why the snapshot captures a bare PATH

The snapshot is generated by spawning a zsh process. In this case, .zshenv sources home-manager's hm-session-vars.sh, which has a guard:

if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi

Claude Desktop inherits __HM_SESS_VARS_SOURCED=1 from the parent login session, so the guard fires and PATH is never set in the snapshot's zsh context. The snapshot captures the bare system PATH.

Suggested Fix

The shell snapshot should not include export PATH=... at all, or env vars from settings.json should be applied after the snapshot is sourced, not before. The env mechanism is the documented way to configure PATH, so it should take precedence.

Workaround

Manually editing the snapshot to remove the export PATH= line works until the snapshot is regenerated.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗