Windows: PowerShell commands incorrectly routed to Bash tool, causing crash
Resolved 💬 2 comments Opened May 11, 2026 by JohnnyChanZY Closed Jun 20, 2026
Summary
On Windows, Claude Code incorrectly routes PowerShell commands (like Test-Path) to the Bash tool instead of the PowerShell tool. When the command fails, the application crashes with undefined is not an object (evaluating 'H.command').
Environment
- OS: Windows 11 Home China 10.0.26200
- Shell: PowerShell 5.1 / Git Bash (MSYS2/MinGW)
Steps to Reproduce
Execute a task involving path validation on Windows, e.g.:
Check if directory D:\毕设\6_毕业答辩 exists
Observed Behavior
Claude Code executed:
Bash(Test-Path "D:\毕设\6_毕业答辩" && "目录存在" || "目录不存在")
Error Output
Error: Exit code 127
/usr/bin/bash: line 1: Test-Path: command not found
Crash
ERROR undefined is not an object (evaluating 'H.command')
B:/~BUN/root/src/entrypoints/cli.js:4931:2966
Root Cause
- Wrong tool selection:
Test-Pathis a PowerShell cmdlet but was routed to Bash tool - Missing null check: Code accesses
H.commandproperty without checking ifHorH.commandis defined
Expected Behavior
- PowerShell commands should use the PowerShell tool on Windows
- Command failures should not crash the application - graceful error handling needed
Impact
- Critical: Application crashes, losing session context
- Affects all Windows users when path validation or other PowerShell commands are needed
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗