[BUG] `pnpm run test` fails with `Error: /d: /d: Is a directory` on Windows
Environment
- Platform (select one):
- [*] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: <!-- output of
claude --version-->
1.0.57 (Claude Code)
- Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
Windows 11 Version 24H2
- Terminal: <!-- e.g. iTerm2, Terminal App -->
Windows Termianl
- Node.js
v22.17.1
- pnpm
10.13.1
Bug Description
On Windows systems, when executing pnpm run test from within a Bash-compatible shell (such as Git Bash or MSYS2), the following error is thrown:
Error: /d: /d: Is a directory
This issue appears to be caused by how Bash interprets drive-letter syntax (/d:), mistaking it for a path or command-line flag, leading to misexecution of the script. The issue does not occur when running the same command in Command Prompt (CMD) or PowerShell.
The error can occur even if the test script itself is minimal, such as:
{
"name": "claude-bugs-with-windows",
"version": "0.1.0",
"description": "claude with pnpm in Windows bugs.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
This suggests the problem lies not within the script contents, but in how pnpm invokes the underlying shell or script runner under Bash on Windows.
Steps to Reproduce
- Create a sample project and initialize with
pnpm:
``bash``
mkdir test-project && cd test-project
pnpm init -y
- Add a dummy test script in
package.json:
``json``
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
- Run the test command:
``bash``
pnpm run test
- Observe the error:
``bash``
Error: /d: /d: Is a directory
Expected behavior
The command pnpm run test should execute the test script successfully in any shell environment, including Git Bash on Windows.
It should behave consistently with CMD or PowerShell.
Actual Behavior
When executed in Git Bash (or similar Bash-compatible environments on Windows), pnpm run test fails with the error:
Error: /d: /d: Is a directory
This indicates that the shell is misinterpreting the drive letter /d: as a malformed path or option, likely due to a discrepancy in how pnpm resolves script paths in Bash vs CMD environments.
Additional Context
- This issue seems specific to Bash-like environments on Windows, such as:
- Git Bash
- MSYS2
- Cygwin
- The error likely arises from how Windows-style drive paths like
/d/or/c/are interpreted by Bash vs Node.js spawn behavior. - This may be related to how
pnpminternally spawns scripts or resolves shell paths when not using native Windows shells. - No such error occurs when using:
cmd.exe- Windows Terminal with PowerShell
- As a workaround, switching to CMD or PowerShell avoids the issue.
If this is a known limitation of cross-shell compatibility, a warning or documentation note may be helpful for developers on Windows using Git Bash.
6 Comments
ACK - we're able to repro this inside git
bash.exeand will share next steps next week.I get a lot of similar issues like that, not only with pnpm. Also with a lot of other native windows executables. It seems like the arguments are not passed correctly.
C&P the printed command
Bash(<Command>)into bash.exe (mingw/msys2, not WSL) works perfectly fine though. Maybe there is some issue with escaping or quoting.This should be resolved in 1.0.68
@ant-kurt the pnpm commands do work for me now.
But for example this command still doesn't work:
dotnet build /p:OpenApiGenerateDocumentsOnBuild=trueIt seems like the slash
/somehow get's modified. Claude code can pass-por--parameterwithout any issues. It's really hard for me to find out what exactly doesn't work, and it's frustrating because claude constantly gets stuck on issues like that.ACK - we're looking at improving reliability with certain sequences (but that is unrelated to the spawn issue in this ticket) - e.g. https://github.com/anthropics/claude-code/issues/4672
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.