claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Bash commands sometimes ends with Error: No such file or directory

Open ALagoni97 opened this issue 1 year ago • 34 comments

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

Image

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"

ALagoni97 avatar Jul 23 '25 16:07 ALagoni97

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

byigitt avatar Jul 23 '25 18:07 byigitt

Same here

! pnpm build ⎿  /usr/bin/bash: Files\git\bin\bash.exe: No such file or directory

arthurlongue avatar Jul 23 '25 22:07 arthurlongue

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.

chsong1 avatar Jul 24 '25 12:07 chsong1

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

eikowagenknecht avatar Jul 24 '25 16:07 eikowagenknecht

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:

Image

tskimmett avatar Jul 24 '25 16:07 tskimmett

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

nickamckenna avatar Jul 25 '25 10:07 nickamckenna

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

byigitt avatar Jul 25 '25 16:07 byigitt

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.

ant-kurt avatar Jul 25 '25 20:07 ant-kurt

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.

@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
Image

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

byigitt avatar Jul 26 '25 06:07 byigitt

I'm not even using CLAUDE_CODE_SHELL_PREFIX.

tskimmett avatar Jul 26 '25 18:07 tskimmett

same problem here

sadimoodi avatar Jul 27 '25 07:07 sadimoodi

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 avatar Jul 27 '25 16:07 PCJones

@PCJones Looks like your problem was more about the note here: https://docs.anthropic.com/en/docs/claude-code/mcp#configure-mcp-servers

Image

tskimmett avatar Jul 27 '25 16:07 tskimmett

@PCJones Looks like your problem was more about the note here: https://docs.anthropic.com/en/docs/claude-code/mcp#configure-mcp-servers Image

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.

PCJones avatar Jul 27 '25 17:07 PCJones

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

itskush avatar Jul 28 '25 16:07 itskush

This is still happening even with both combinations of ENV variables, does anyone know the fix??

gt732 avatar Jul 30 '25 20:07 gt732

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.

eikowagenknecht avatar Jul 30 '25 20:07 eikowagenknecht

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 :(

gt732 avatar Jul 30 '25 20:07 gt732

Seeing the same issue on both Windows 10 and 11.

nwly avatar Jul 30 '25 20:07 nwly

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.

shm4r7 avatar Jul 30 '25 20:07 shm4r7