[BUG] env.PATH in settings.json not applied when running Bash commands inside a git worktree

Resolved 💬 3 comments Opened Apr 7, 2026 by idanizi Closed Apr 10, 2026

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

  1. Open a project that uses git worktrees
  2. Enter a worktree (e.g. via EnterWorktree / a worktree-based agent)
  3. 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:

  1. Configure env.PATH in ~/.claude/settings.json to include /opt/homebrew/bin
  2. Open a project in Claude Code
  3. Have Claude Code spin up an agent in a git worktree (e.g. via the EnterWorktree tool or by starting a task that uses isolation: "worktree")
  4. 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_

View original on GitHub ↗

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