Worktree-isolated sessions refuse git after `cd ~/path` but allow the same command with `"$HOME/path"` (2.1.278)
When a session runs inside a git worktree, Claude Code refuses a Bash command that changes directory with a ~ path
and then runs git, even when the target is a different repository. The same command passes when the path is written
as "$HOME/…" or typed out in full, so the refusal is about path spelling, not about where git runs.
Environment: Claude Code 2.1.278, macOS (Darwin 24.6.0), zsh, session working directory<repo>/.claude/worktrees/<name>.
Reproductions, each one Bash tool call from the worktree session, <other> being a separate repository:
cd ~/src/<other> && git status -sbis refused: "this command changes directory to a location computed at
runtime before running git."
cd "$HOME/src/<other>" && git status -sbis allowed.cd /Users/<user>/src/<other> && git status -sbis allowed.git -C ~/src/<other> status -sbis refused: "points git at a directory computed at runtime (-C
~/src/<other>)".
git -C /Users/<user>/src/<other> status -sbis allowed.
Control: cd "$HOME/src/<this-repo>" && git status -sb is refused as "the shared checkout
(/Users/<user>/src/<this-repo>)", which shows the check already resolves $HOME before it runs.
Expected: ~ and ~/… resolve the same way $HOME does. Tilde expansion is fixed at parse time, so it is not
computed at runtime.
Impact: one machine logged 62 refusals in one night, almost all cd ~/src/<repo> && git fetch|status|grep|worktree against sibling repositories, while a session searched 15 repositories for the one that owned a ticket.
list
Related: #94040 covers worktree-isolated sessions refusing commands that never run git. This report is a separate
case: a command that does run git, refused only because of how its path is spelled.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗