[BUG] Bash commands sometimes ends with Error: No such file or directory
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 1.0.58
- Operating System: Windows 11
- Terminal: Warp - Git Bash
Bug Description
The first few commands with pnpm runs correct, but then suddenly it doesn't. I am not sure what is going here. There are other pnpm commands that doesn't work.
Steps to Reproduce
Honestly not sure. This might be a dumb issue that only I encounter...
Expected Behavior
That every command with pnpm runs correctly.
Actual Behavior
It ends up with a Error: /c/Program: Files\Git\usr\bin\bash.exe: No such file or directory
Additional Context
I am running my git bash in an e/Github/project folder
I followed this: https://docs.anthropic.com/en/docs/claude-code/setup
First i ran this command to make sure i had the folder structure for my bash:
where bash:
It showed this folder:
C:\Program Files\Git\usr\bin\bash.exe
So i just changed the guides path to my, so my command was this: $env:CLAUDE_CODE_GIT_BASH_PATH="C:\Program Files\Git\usr\bin\bash.exe"
I get the same thing aswell.
> Can you run pnpm --version
● I'll check the pnpm version for you.
● Bash(pnpm --version)
⎿ Error: /usr/bin/bash: Files\Git\bin\bash.exe: No such file
or directory
Same here
! pnpm build ⎿ /usr/bin/bash: Files\git\bin\bash.exe: No such file or directory
I have the same environment as above, windows 11, warp and same error as your question.
I have set the CLAUDE_CODE_GIT_BASH_PATH environment variable, but I still get the same problem.
I also have a variation of this problem:
Environment
- Windows 11
This happens when running Claude in the VS Code extension, in a Powershell or in Git bash.
What Claude says to see from the bash
- Unix path: /usr/bin/bash
- Real Windows path: C:\Program Files\Git\usr\bin\bash.exe
- Bash version: GNU bash 5.2.37(1)-release (x86_64-pc-msys)
- File type: PE32+ executable (Windows executable)
Problem
Runing pnpm commands fails with error: /usr/bin/bash: Files\Git\bin\bash.exe: No such file or directory.
Somehow the SHELL path gets corrupted.
- Simple bash commands work: echo "hello", ls, pwd
- Direct commands work: pnpm --version, node --version
- Fails:
pnpm run test:coverage("test:coverage": "vitest run --coverage")- Fails with: /usr/bin/bash: Files\Git\bin\bash.exe: No such file or directory
- Works for some reason:
npx vitest run --coverage
Attempted Solutions
- Setting CLAUDE_CODE_GIT_BASH_PATH environment variable - did not help
Yes, this has been plaguing me as well. It seems like claude is trying to use its git bash environment variable from within git bash, which of course doesn't work because it isn't using the unix style path. Manually testing this theory shows the same type of error:
I think that this may also be causing a bug I just reported here: https://github.com/anthropics/claude-code/issues/4382
I am also able to repeat the problem reliably with a simple prompt:
Can you execute the command pwd
● Bash(pwd) ⎿ Error: /usr/bin/bash: line 1: C:Program: command not found
● Bash(cd) ⎿ Error: /usr/bin/bash: line 1: C:Program: command not found
I have two environment variables set:
CLAUDE_CODE_GIT_BASH_PATH C:\Program Files\Git\bin\bash.exe CLAUDE_CODE_SHELL_PREFIX C:\Program Files\Git\bin\bash.exe
Yeah, I get the same errors aswell @nickamckenna:
● Bash(npx create-next-app@latest ant-design-dashboard --typescript --tailwind --app --src-dir --import-alias "@/*"
--no-git)
⎿ Error: /usr/bin/bash: line 1: C:Program: command not found
● Bash(npx create-next-app@latest . --typescript --tailwind --app --src-dir --import-alias "@/*")
⎿ Error: /usr/bin/bash: line 1: C:Program: command not found
Yes, this has been plaguing me as well. It seems like claude is trying to use its git bash environment variable from within git bash, which of course doesn't work because it isn't using the unix style path.
Currently there is a conflict between CLAUDE_CODE_GIT_BASH_PATH and CLAUDE_CODE_SHELL_PREFIX that results in this behavior (trying to use the SHELL_PREFIX path from inside the GIT_BASH_PATH executable). As a workaround, you may need to stop specifying CLAUDE_CODE_SHELL_PREFIX for now - we're working on a longer term fix here.
Yes, this has been plaguing me as well. It seems like claude is trying to use its git bash environment variable from within git bash, which of course doesn't work because it isn't using the unix style path.
Currently there is a conflict between
CLAUDE_CODE_GIT_BASH_PATHandCLAUDE_CODE_SHELL_PREFIXthat results in this behavior (trying to use the SHELL_PREFIX path from inside the GIT_BASH_PATH executable). As a workaround, you may need to stop specifyingCLAUDE_CODE_SHELL_PREFIXfor now - we're working on a longer term fix here.
@ant-kurt,
Even though I removed CLAUDE_CODE_SHELL_PREFIX and only having CLAUDE_CODE_GIT_BASH_PATH - I still get the same error.
> use pnpm build
● I'll run the build command for you.
● Bash(cd /Users/user/Desktop/xxxx/xxxx && pnpm build)
⎿ Error: /usr/bin/bash: line 1: C:Program: command not found
I got the same variable in System Variables aswell.
Also, when I restart the terminal to get the CLAUDE_CODE_SHELL_PREFIX variable to be zeroed, now I get this error:
xxx-dev on dev [$!?] via v22.14.0
❯ echo $env:CLAUDE_CODE_GIT_BASH_PATH
C:\Program Files\Git\bin\bash.exe
xxx-dev on dev [$!?] via v22.14.0
❯ echo $env:CLAUDE_CODE_SHELL_PREFIX
xxx-dev on dev [$!?] via v22.14.0
❯ claude
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Do you trust the files in this folder? │
│ │
│ C:\Users\user\Desktop\xxx\xxx-dev │
│ │
│ Claude Code may read files in this folder. Reading untrusted files may lead Claude Code to behave in unexpected ways. │
│ │
│ With your permission Claude Code may execute files in this folder. Executing untrusted code is unsafe. │
│ │
│ https://docs.anthropic.com/s/claude-code-security │
│ │
│ ❯ 1. Yes, proceed │
│ 2. No, exit │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Enter to confirm · Esc to exit
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: C:\Users\user\Desktop\xxx\xxx-dev │
╰───────────────────────────────────────────────────╯
※ Tip: Use /theme to change the color theme
> use pnpm typecheck
● I'll help you run the type check for your project. Let me execute the pnpm typecheck command.
● Bash(pnpm typecheck)
⎿ Error: /usr/bin/bash: Files\Git\bin\bash.exe: No such file or directory
I'm not even using CLAUDE_CODE_SHELL_PREFIX.
same problem here
I found a workaround.
Problematic config:
"sequential-thinking": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sequential-thinking"
]
}
Workaround:
"sequential-thinking": {
"type": "stdio",
"command": "C:\\Program Files\\Git\\bin\\bash.exe",
"args": [
"-c",
"npx -y @modelcontextprotocol/server-sequential-thinking"
]
}
@PCJones Looks like your problem was more about the note here: https://docs.anthropic.com/en/docs/claude-code/mcp#configure-mcp-servers
@PCJones Looks like your problem was more about the note here: https://docs.anthropic.com/en/docs/claude-code/mcp#configure-mcp-servers
No, it was the error described in this issue. I just used this npx command as example, this also fixes it for non-npx commands.
don't know if this is related, but when running pnpm commands it opens a new powershell windows for me and then ignores that terminal
This is still happening even with both combinations of ENV variables, does anyone know the fix??
Not a fix of this problem per se, but this bug led me to run Claude Code inside WSL2 instead, which works just fine. Might be a valid alternative if your environment allows it.
Not a fix of this problem per se, but this bug led me to run Claude Code inside WSL2 instead, which works just fine. Might be a valid alternative if your environment allows it.
I would do that but working on a mobile app with flutter and everything works fine within android studio/windows. This is making me reach my limit so much quicker cause it keeps trying so I'm assuming that's another api call each time it screws up :(
Seeing the same issue on both Windows 10 and 11.
Same issue here, bash commands have nto worked for me for few days already. I hope it get prioritized, going back to WSL after it worked in native windows is not a cool option.
