[BUG] env.PATH in settings.json not applied when running Bash commands inside a git worktree
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
The env.PATH setting configured in settings.json (global, project, and
worktree levels) is not applied when Claude Code runs Bash commands inside a
git worktree. Instead, the shell receives the bare macOS PATH.
Environment
- OS: macOS Darwin 25.4.0 (arm64)
- Shell: zsh
Configuration
All three settings files have the correct PATH:
~/.claude/settings.json (global):
{
"env": {
"PATH": "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
}
}
Same env.PATH is also set in the project-level and worktree-level
.claude/settings.local.json files.
Steps to Reproduce
- Open a project that uses git worktrees
- Enter a worktree (e.g. via EnterWorktree / a worktree-based agent)
- 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
Impact
Any Homebrew-installed tool (brew, gh, node, npx, etc.) is unavailable inside
worktrees, even though the env setting is correctly configured everywhere.
What Should Happen?
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Error Messages/Logs
Steps to Reproduce
Based on what we observed in this session:
- Configure
env.PATHin~/.claude/settings.jsonto include/opt/homebrew/bin - Open a project in Claude Code
- Have Claude Code spin up an agent in a git worktree (e.g. via the
EnterWorktreetool or by starting a task that usesisolation: "worktree") - Inside the worktree 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
---
One caveat: I can't confirm whether this reproduces outside of the Claude Agent SDK worktree context (i.e. isolation: "worktree" in the Agent tool), vs. a manually entered worktree via EnterWorktree. Worth testing both to narrow it down.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.85
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗