[BUG] CLI fails on Windows with Git Bash: "No suitable shell found"
Bug Description
The Claude Code CLI fails to initialize when run within the Git Bash environment on Windows. It reports that "No suitable shell found," even though the SHELL environment variable is correctly set and the system is a standard Git for Windows installation.
This issue occurs with a local (project-level) installation of the package. This prevents users on Windows who cannot use WSL (due to corporate policy, etc.) from using the CLI tool.
To Reproduce
- On a Windows machine, install Git for Windows to get the Git Bash terminal.
- Open the Git Bash terminal.
- Create a new directory for a project:
mkdir test-claude-cli && cd test-claude-cli - Install Claude Code locally in the project:
npm install @anthropic-ai/claude-code@latest - Attempt to run the CLI using
npx:npx claude - The error "No suitable shell found" is displayed immediately.
Expected Behavior
The CLI should successfully detect the Posix-compliant shell provided by Git Bash and start normally, proceeding to the authentication/project setup steps.
Actual Behavior
The CLI exits immediately with the following error message:
Error: No suitable shell found. Claude CLI requires a Posix shell environment. Please ensure you have a valid shell installed and the SHELL environment variable set.
Environment Details
- OS: Windows 11 Pro
- Terminal: Git Bash (MINGW64)
- Node.js Version: v22.17.0
@anthropic-ai/claude-codeVersion: 1.0.51
Diagnostic Information
The Git Bash environment appears to be correctly configured:
$ echo $SHELL
/usr/bin/bash
$ which bash
/usr/bin/bash
The issue also persists even when explicitly setting the SHELL variable before running the command:
$ SHELL=/usr/bin/bash npx claude
# Same "No suitable shell found" error occurs
23 Comments
Use PowerShell, not bash, you just need git-bash installed. Also, make sure node. is installed in its normal global location (and there's nothing in your path pointing to a different location like a dedicated npm directory)
Thank you for the quick and helpful response!
Your advice solved the problem. I was able to run it successfully from PowerShell within the project directory.
The "No suitable shell found" error was a bit misleading, as it made me focus entirely on Git Bash. I appreciate you pointing me in the right direction.
Thanks again for your help!
No problem. I had the same issue because it was equally as misleading to not specify in the changenotes.md nor add any windows installation instructions. Gotta love Anthropic.
when you say normal npm global location, what is the expected normal in a Windows environment? (or rather what is normal for this context).
My Experience and Technical Analysis
I encountered the exact same issue and need to point out some serious problems with this codebase:
Current Situation
$env:SHELL = "C:\Program Files\Git\bin\bash.exe"in PowerShell ❌export SHELL=/usr/bin/bashin Git Bash ❌npx @anthropic-ai/claude-codedirectly ❌The Real Problem: Fundamentally Broken Shell Detection
Looking at the error stack trace in
cli.js:712, the shell detection logic is architecturally flawed:Why This Code is Broken
which bashreturns/usr/bin/bash, butfs.accessSync()can't find this virtual path in Windows filesystemWhat Should Have Been Done
Current Workaround Status
The "use PowerShell instead" suggestion works, but it's a band-aid solution that:
Request for Proper Fix
This isn't just a configuration issue - it's a design flaw that needs proper Windows compatibility. The shell detection should:
Please consider implementing proper cross-platform shell detection rather than suggesting workarounds that bypass the real problem.
---
Environment Details:
I have to add that on my case, the _open it in powershell_ doesn't solve my issue despite having a generic npm/node installation on Windows. In my case, node version is 22.11.0 (npm 11.2.0)
I encountered the exact same issue and frankly, this is ridiculous that such a basic Windows compatibility problem exists in production.
Here's a quick and dirty fix I found:
In
cli.jsaround line 712, in theyw0function, add this single line afterlet W=Y.find((J)=>J&&Sw0(J));:I encountered the same issue
Unable to start on PowerShell; it always thinks there's an issue with my bash. I can only switch to bash to work.
try npx win-claude-code if you're using Windows.
Program Files on windows is the normal location. Some people move it to a different location like /User/Home or C:/Users/User. That's where i had it and every time I tried to launch Claude, it would look for a file in the @anthropic-ai/claude-code folder that normally would be in the default location but wasn't for me.
If your error says anything about a missing file named cli.js, your problem is node's install location
to find the cli.js file:
No Git Bash
echo $APPDATA
https://zenn.dev/tkfoot/articles/claude-code-windows-support 这里有解决方案
thank you so much! your article FIX my issues. turns out its about
CLAUDE_CODE_GIT_BASH_PATHi have compile a ps1 script to install and set the env variables:
irm https://gist.githubusercontent.com/fatihaziz/c9f2c5d60ef1c2327b7767ac6c69a98c/raw/claude_install_windows.ps1 | iexSet Environment Variable:
Fixed!
I can verify that (for me) the CLAUDE_CODE_GIT_BASH_PATH user environment variable was required for Claude Code to work under native Windows, as per the instructions in this video:
How to Install Claude Code on Windows (natively!)
<img width="657" height="169" alt="Image" src="https://github.com/user-attachments/assets/c22f8c95-ca90-4364-8b01-4fdf67754639" />
It fixed but still have problem with:
If you are using Windows PowerShell, you can use the following settings
Note: This only works for the current terminal
It may help some users to know that git for windows may have installed in the $LOCALAPPDATA folder. i.e.
C:\Users\your.name\AppData\Local\Programs\Git\cmd\git.exe- rather than inC:\Program Files\git\bin\bash.exeTo find out exactly where git is installed, from a git bash terminal, if you run
where gitit will output the correct path.Then just take that path and put it into you USER Environment Variables under
CLAUDE_CODE_GIT_BASH_PATHWidows env vars
CLAUDE_CODE_GIT_BASH_PATHwhere gitcommand run in git bash.claude, or reboot if still not working and try again.Quick Fix: "No suitable shell found" on Windows (using --ignore-scripts)
This method helps bypass installation script failures that often lead to the "No suitable shell found" error on Windows.
Node.js: Ensure you have Node.js version 18 or newer installed. (v22+ is generally recommended for better compatibility).
Open your PowerShell or Command Prompt (it's safer to use these for the install, not Git Bash directly, to avoid potential conflicts with scripts).
Run the following command:
bash npm install -g @anthropic-ai/claude-code --ignore-scripts
The --ignore-scripts flag is crucial here. It prevents pre- and post-installation scripts, which might rely on POSIX environments, from running and potentially failing on Windows.
After the installation completes, open a new Git Bash terminal.
Navigate to your project directory.
Simply type claude and hit Enter.
Claude Code should now detect your shell and proceed with the authentication/setup steps
Hey folks, sorry for the confusion here. Here's a summary of where we're at:
bash.exeon some environments. We have issued a patch for this in v1.0.56 (note this is not tagged aslatestyet at the time of writing).bash.exewill be found correctly - or you will get a (more) helpful error message about setting the environment variable:CLAUDE_CODE_GIT_BASH_PATHto the Windows path where yourbash.exeis. It's probably something likeC:\Program Files\git\bin\bash.exe. Otherwise, you can find this by runningwhere.exe gitand then looking at the parent folders of the results.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.