claude-code - 💡(How to fix) Fix [BUG] Windows: file existence check uses cmd.exe dir instead of fs.existsSync, fails when cmd.exe is blocked by corporate policy [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45118Fetched 2026-04-09 08:12:50
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

Error Message

Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "C:\Program Files\Git\bin\bash.exe"

VS Code Extension log: 2026-04-08 12:28:26.052 [info] From claude: Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "C:\Program Files\Git\bin\bash.exe" 2026-04-08 12:28:26.077 [error] Error spawning Claude (on channel x0zbuqiuib): Error: Query closed before response received Proof that the file exists and is accessible: PS> & "C:\Program Files\Git\bin\bash.exe" --version GNU bash, version 5.2.37(1)-release (x86_64-pc-msys)

PS> node -e "const fs = require('fs'); try { fs.accessSync('C:\Program Files\Git\bin\bash.exe', fs.constants.R_OK | fs.constants.X_OK); console.log('OK'); } catch(e) { console.log('FAIL:', e.message); }" OK Root cause in cli.js - function f28() uses dir command: javascriptfunction f28(q){ try{ return Sf6(dir "${q}",{stdio:"pipe"}),!0 } catch{ return!1 } } Suggested fix: javascriptconst fs = require('fs'); function f28(q){ try{ fs.accessSync(q, fs.constants.R_OK); return true } catch{ return false } }

Root Cause

PS> node -e "const fs = require('fs'); try { fs.accessSync('C:\Program Files\Git\bin\bash.exe', fs.constants.R_OK | fs.constants.X_OK); console.log('OK'); } catch(e) { console.log('FAIL:', e.message); }" OK Root cause in cli.js - function f28() uses dir command: javascriptfunction f28(q){ try{ return Sf6(dir "${q}",{stdio:"pipe"}),!0 } catch{ return!1 } } Suggested fix: javascriptconst fs = require('fs'); function f28(q){ try{ fs.accessSync(q, fs.constants.R_OK); return true } catch{ return false } }

Fix Action

Fix / Workaround

This issue makes Claude Code completely unusable in corporate Windows environments where cmd.exe is restricted — which is a very common enterprise security policy. The fix is trivial (fs.accessSync instead of execSync('dir ...')) and would unblock corporate users. There is currently no workaround unless WSL is available on the machine. Node.js version: v24.12.0.

Code Example

Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "C:\Program Files\Git\bin\bash.exe"

VS Code Extension log:
2026-04-08 12:28:26.052 [info] From claude: Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "C:\Program Files\Git\bin\bash.exe"
2026-04-08 12:28:26.077 [error] Error spawning Claude (on channel x0zbuqiuib): Error: Query closed before response received
Proof that the file exists and is accessible:
PS> & "C:\Program Files\Git\bin\bash.exe" --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-msys)

PS> node -e "const fs = require('fs'); try { fs.accessSync('C:\\Program Files\\Git\\bin\\bash.exe', fs.constants.R_OK | fs.constants.X_OK); console.log('OK'); } catch(e) { console.log('FAIL:', e.message); }"
OK
Root cause in cli.js - function f28() uses dir command:
javascriptfunction f28(q){
  try{ return Sf6(`dir "${q}"`,{stdio:"pipe"}),!0 }
  catch{ return!1 }
}
Suggested fix:
javascriptconst fs = require('fs');
function f28(q){
  try{ fs.accessSync(q, fs.constants.R_OK); return true }
  catch{ return false }
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code fails to start on Windows when cmd.exe is blocked by corporate Group Policy (GPO). The file existence check function uses execSync('dir "path"') which internally invokes cmd.exe. When cmd.exe is restricted, this check fails even though bash.exe exists and is fully accessible. This affects both the terminal CLI and the VS Code extension, making Claude Code completely unusable.

What Should Happen?

Claude Code should start normally since bash.exe exists at the specified path and is accessible by Node.js. The file existence check should use fs.accessSync() or fs.existsSync() instead of cmd.exe-dependent dir command.

Error Messages/Logs

Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "C:\Program Files\Git\bin\bash.exe"

VS Code Extension log:
2026-04-08 12:28:26.052 [info] From claude: Claude Code was unable to find CLAUDE_CODE_GIT_BASH_PATH path "C:\Program Files\Git\bin\bash.exe"
2026-04-08 12:28:26.077 [error] Error spawning Claude (on channel x0zbuqiuib): Error: Query closed before response received
Proof that the file exists and is accessible:
PS> & "C:\Program Files\Git\bin\bash.exe" --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-msys)

PS> node -e "const fs = require('fs'); try { fs.accessSync('C:\\Program Files\\Git\\bin\\bash.exe', fs.constants.R_OK | fs.constants.X_OK); console.log('OK'); } catch(e) { console.log('FAIL:', e.message); }"
OK
Root cause in cli.js - function f28() uses dir command:
javascriptfunction f28(q){
  try{ return Sf6(`dir "${q}"`,{stdio:"pipe"}),!0 }
  catch{ return!1 }
}
Suggested fix:
javascriptconst fs = require('fs');
function f28(q){
  try{ fs.accessSync(q, fs.constants.R_OK); return true }
  catch{ return false }
}

Steps to Reproduce

Use a Windows machine where cmd.exe is blocked by corporate Group Policy Install Git for Windows at default location (C:\Program Files\Git) Set environment variable: CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\Git\bin\bash.exe Run claude from PowerShell or Git Bash Claude Code exits with "unable to find CLAUDE_CODE_GIT_BASH_PATH path" error Same result occurs when using VS Code extension

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.96 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

This issue makes Claude Code completely unusable in corporate Windows environments where cmd.exe is restricted — which is a very common enterprise security policy. The fix is trivial (fs.accessSync instead of execSync('dir ...')) and would unblock corporate users. There is currently no workaround unless WSL is available on the machine. Node.js version: v24.12.0.

extent analysis

TL;DR

Replace the execSync('dir "path"') call in cli.js with fs.accessSync() to fix the issue with Claude Code failing to start on Windows due to blocked cmd.exe.

Guidance

  • Identify the f28 function in cli.js and replace it with the suggested fix using fs.accessSync() to check for file existence and accessibility.
  • Verify that the fs module is properly required and imported in the modified code.
  • Test the modified code on a Windows machine with cmd.exe blocked by corporate Group Policy to ensure Claude Code starts correctly.
  • Consider adding error handling for cases where fs.accessSync() fails, to provide more informative error messages.

Example

const fs = require('fs');
function f28(q){
  try{ 
    fs.accessSync(q, fs.constants.R_OK); 
    return true 
  }
  catch{ 
    return false 
  }
}

Notes

This fix assumes that the fs module is available and functional in the Node.js environment. If issues persist, verify the Node.js version and fs module functionality.

Recommendation

Apply the suggested workaround by replacing execSync('dir "path"') with fs.accessSync() to unblock corporate users and allow Claude Code to start normally on Windows machines with restricted cmd.exe.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING