[BUG] Windows/Git Bash: if the 10-second login-shell PATH probe times out, the Bash tool loses PATH for the whole session

Status Open
Reported on v2.1.296
Maintainer reply None cached
Activity 1 comment · opened Oct 11, 2026

Summary

On Windows with Git Bash, Claude Code reads the PATH for a new session's Bash tool by running a login shell, with a fixed 10-second timeout.
If that login shell is briefly slow, for example while several sessions are running, the probe times out.
Claude Code then silently uses the Windows-format PATH instead, and every Bash command in that session fails until a new session is started.

Environment

Claude Code 2.1.296 (VS Code extension), Windows 11, Git for Windows bash.

What

  • Every Bash tool call fails with exit 127: git, gh, head, and even bash are not found.
  • This lasts for the whole session.
  • Other sessions are not affected.

When

  • At session start, if the machine is briefly under load. For example, when several sessions have been running at once for hours.
  • A session created a minute later gets a correct PATH.
  • A Git Bash login shell takes 2–3 seconds even when idle, so a short burst of load can push it past 10 seconds.

Why

  1. At session start, Claude Code runs bash -lc 'echo "$PATH"' with timeout: 10000 (10 seconds).
  2. If that call fails or times out, it keeps the process PATH, which is in Windows format (C:\...;C:\...). No warning is shown.
  3. That PATH is written into the session's shell snapshot.
  4. If the snapshot-creation login shell that runs next succeeds, the broken snapshot is reused for every Bash call.

Reproduction (no settings, hooks or MCP)

This setup makes only the first login shell take longer than 10 seconds:

mkdir -p /tmp/fh/work && cd /tmp/fh/work
printf 'if [ ! -f "$HOME/.slow" ]; then touch "$HOME/.slow"; sleep 12; fi\n' > /tmp/fh/.bash_profile
HOME=/tmp/fh claude -p 'Run: printf "%s\n" "$PATH" | head -c 120; command -v git || echo NO_GIT' --setting-sources "" --strict-mcp-config --allowedTools Bash --model haiku
  • Result: head: command not found and NO_GIT.
  • Without the sleep: you get a normal /mingw64/bin:/usr/bin:... PATH and git is found.
  • If every login shell sleeps: the output is also correct. Snapshot creation times out too, so Claude Code falls back to a login shell for each command.

How to confirm on an affected session

The session's ~/.claude/shell-snapshots/snapshot-bash-*.sh contains a Windows-format PATH:

export PATH='C:\Program Files\PowerShell\7;C:\WINDOWS\system32;...'

A healthy snapshot has export PATH='/mingw64/bin:/usr/bin:...' instead.

Suggested fix

  • When the probe fails, don't write the Windows-format PATH to the snapshot. Do one of these instead:
  • convert it, for example with cygpath -p -u, and prepend /usr/bin;
  • retry the probe;
  • fall back to a login shell for each command, as Claude Code already does when snapshot creation fails.
  • Log a warning when the probe fails or times out.
  • Optionally, make the 10-second timeout configurable on Windows.

Related

#81356, #31799 and #38951 are other ways the snapshot's export PATH line breaks. Their causes are different.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗