[BUG] CLI fails on Windows with Git Bash: "No suitable shell found"

Resolved 💬 23 comments Opened Jul 14, 2025 by 0x46y Closed Jul 19, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

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

  1. On a Windows machine, install Git for Windows to get the Git Bash terminal.
  2. Open the Git Bash terminal.
  3. Create a new directory for a project: mkdir test-claude-cli && cd test-claude-cli
  4. Install Claude Code locally in the project: npm install @anthropic-ai/claude-code@latest
  5. Attempt to run the CLI using npx: npx claude
  6. 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-code Version: 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

View original on GitHub ↗

23 Comments

Sallvainian · 1 year ago

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)

0x46y · 1 year ago

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!

Sallvainian · 1 year ago

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.

asfar-decmil · 1 year ago
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)

when you say normal npm global location, what is the expected normal in a Windows environment? (or rather what is normal for this context).

floydchenv · 1 year ago

My Experience and Technical Analysis

I encountered the exact same issue and need to point out some serious problems with this codebase:

Current Situation

  • Environment: Windows 11, Git Bash (MINGW64), Node.js v18.20.7
  • Error: Same "No suitable shell found" error
  • Attempted Solutions:
  • Set $env:SHELL = "C:\Program Files\Git\bin\bash.exe" in PowerShell ❌
  • Set export SHELL=/usr/bin/bash in Git Bash ❌
  • Used npx @anthropic-ai/claude-code directly ❌

The Real Problem: Fundamentally Broken Shell Detection

Looking at the error stack trace in cli.js:712, the shell detection logic is architecturally flawed:

// Hard-coded Unix paths that don't exist on Windows
G=["/bin","/usr/bin","/usr/local/bin","/opt/homebrew/bin"]

// Relies on `which` command that returns non-existent paths on Windows
su1(`which ${J}`, {stdio:["ignore","pipe","ignore"]})

// Uses Unix file permission checks on Windows paths
v1().accessSync(A,h9Q.X_OK)

Why This Code is Broken

  1. Platform Ignorance: The code assumes Unix file system structure even on Windows
  2. Path Resolution Failure: Git Bash's which bash returns /usr/bin/bash, but fs.accessSync() can't find this virtual path in Windows filesystem
  3. Missing Windows Compatibility: Zero consideration for Windows path formats or Git Bash's MSYS2 environment
  4. Misleading Error Message: "No suitable shell found" when the real issue is broken path detection

What Should Have Been Done

function detectShell() {
  if (process.platform === 'win32') {
    // Windows-specific shell detection
    const candidates = [
      process.env.SHELL,
      'C:/Program Files/Git/bin/bash.exe',
      'C:/Program Files/Git/usr/bin/bash.exe'
    ];
    return candidates.find(path => path && fs.existsSync(path));
  }
  // Unix logic here...
}

Current Workaround Status

The "use PowerShell instead" suggestion works, but it's a band-aid solution that:

  • Doesn't fix the underlying architectural problem
  • Forces Windows users into a suboptimal workflow
  • Ignores the fact that many developers prefer Git Bash for its Unix-like environment

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:

  1. Handle Windows path formats correctly
  2. Properly detect Git Bash installations
  3. Provide meaningful error messages
  4. Not assume Unix-only environments

Please consider implementing proper cross-platform shell detection rather than suggesting workarounds that bypass the real problem.

---

Environment Details:

  • OS: Windows 10
  • Terminal: Git Bash (MINGW64)
  • Node.js: v18.20.7
  • Package: @anthropic-ai/claude-code@latest
asfar-decmil · 1 year ago

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)

floydchenv · 1 year ago

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.js around line 712, in the yw0 function, add this single line after let W=Y.find((J)=>J&&Sw0(J));:

if(process.platform==='win32'&&!W&&v1().existsSync('C:/Program Files/Git/bin/bash.exe'))W='C:/Program Files/Git/bin/bash.exe';
Lambdua · 1 year ago

I encountered the same issue

Alphayellowcat · 1 year ago

Unable to start on PowerShell; it always thinks there's an issue with my bash. I can only switch to bash to work.

VincentPeng207 · 1 year ago

try npx win-claude-code if you're using Windows.

Sallvainian · 1 year ago
> 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) when you say normal npm global location, what is the expected normal in a Windows environment? (or rather what is normal for this context).

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

guidogabriel · 1 year ago
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.js around line 712, in the yw0 function, add this single line after let W=Y.find((J)=>J&&Sw0(J));: if(process.platform==='win32'&&!W&&v1().existsSync('C:/Program Files/Git/bin/bash.exe'))W='C:/Program Files/Git/bin/bash.exe';

to find the cli.js file:

No Git Bash

echo $APPDATA

qq244432779 · 1 year ago
fatihaziz · 1 year ago
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_PATH

fatihaziz · 1 year ago

i have compile a ps1 script to install and set the env variables:
irm https://gist.githubusercontent.com/fatihaziz/c9f2c5d60ef1c2327b7767ac6c69a98c/raw/claude_install_windows.ps1 | iex

Yogioo · 1 year ago

Set Environment Variable:

CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\git\bin\bash.exe

Fixed!

Maury1329 · 1 year ago

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" />

guidogabriel · 1 year ago
https://zenn.dev/tkfoot/articles/claude-code-windows-support 这里有解决方案

It fixed but still have problem with:

  • MCPs and
  • Shift + TAB to change plan mode
xianjianlf2 · 1 year ago

If you are using Windows PowerShell, you can use the following settings
Note: This only works for the current terminal

$env:CLAUDE_CODE_GIT_BASH_PATH="C:\Program Files\git\bin\bash.exe"
claude
heresandyboy · 1 year ago

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 in C:\Program Files\git\bin\bash.exe

To find out exactly where git is installed, from a git bash terminal, if you run
where git it will output the correct path.
Then just take that path and put it into you USER Environment Variables under CLAUDE_CODE_GIT_BASH_PATH

Widows env vars

  • Right click windows logo on the taskbar
  • Click 'System'
  • Click 'Advanced system settings'
  • System Properties window opens, click 'Environment Variables'
  • In the Environment Variables window, Under 'User variables', click 'New...'
  • Variable Name: CLAUDE_CODE_GIT_BASH_PATH
  • Variable value: enter whatever path you got from the where git command run in git bash.
  • Then either close and re-open any terminals and try to run claude, or reboot if still not working and try again.
davidassef · 12 months ago

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.

  1. Prerequisites:

Node.js: Ensure you have Node.js version 18 or newer installed. (v22+ is generally recommended for better compatibility).  

  1. Install Claude Code Globally (with the magic flag):

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.  

  1. Run Claude Code:

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

ant-kurt collaborator · 12 months ago

Hey folks, sorry for the confusion here. Here's a summary of where we're at:

  • There is a code defect preventing Claude Code from finding git's bash.exe on some environments. We have issued a patch for this in v1.0.56 (note this is not tagged as latest yet at the time of writing).
  • With that patch, either bash.exe will be found correctly - or you will get a (more) helpful error message about setting the environment variable:
  • In the meantime, if you're running into this issue, set environment variable CLAUDE_CODE_GIT_BASH_PATH to the Windows path where your bash.exe is. It's probably something like C:\Program Files\git\bin\bash.exe. Otherwise, you can find this by running where.exe git and then looking at the parent folders of the results.
github-actions[bot] · 11 months ago

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.