[BUG] cygpath calls on Windows seems to slown down agent a lot

Status Fixed / completed
Maintainer reply None cached
Activity 6 comments · opened Nov 27, 2025 · closed Jan 13, 2026

Preflight Checklist

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

What's Wrong?

The clauding animation is pausing. CC freezes for a 1 to 5 seconds doing something in backgroud, so I inspected the task manager and seen cygpath long calls exactly the times CC freezes.

I think this is last weeks issue.

What Should Happen?

No freezes :)

Error Messages/Logs

Steps to Reproduce

Just usual CC sessions. After 1-5 messages these freezes appears.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.55 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

VSCode integrated terminal - PowerShell

View original on GitHub ↗

6 Comments

honix · 10 months ago

Hey, there is my research results with Opus on this issue.

# Claude Code Windows Performance Issue - Detailed Report ## Summary Claude Code on Windows experiences 5-30 second delays due to MSYS2 runtime initialization when calling bash.exe for path conversion operations. ## Environment - OS: Windows (domain-joined corporate machine) - Git Installation: C:\Program Files\Git (Git for Windows / MSYS2-based) - Shell: PowerShell - No issues on WSL - only native Windows ## Root Cause Claude Code calls bash.exe to run cygpath: `` "C:\Program Files\Git\bin\bash.exe" -c "cygpath -u 'C:\path\to\file'" ` The bash.exe (MSYS2 binary) has severe cold-start overhead: `powershell PS> Measure-Command { & "C:\Program Files\Git\bin\bash.exe" -c "echo hello" } TotalSeconds : 28.4885132 ` **28 seconds** just to echo "hello". ## Why MSYS2 is Slow on Domain Machines Every MSYS2 executable initialization: 1. Loads msys-2.0.dll (POSIX emulation layer) 2. Initializes shared "cygheap" memory segment 3. **Queries Active Directory for user/group info** ← Main bottleneck 4. Sets up signal handlers, terminal info, mount tables 5. Then finally runs the actual command On domain-joined machines, step 3 can take 10-30 seconds, especially: - First call after cache expires - Concurrent calls (mutex locking on shared cygheap) - VPN/network latency to domain controllers ## Observed Behavior | Scenario | Time | |----------|------| | First cygpath call | ~29 seconds | | Subsequent calls (cached) | ~66ms | | After ~10-20 calls | Slow again (cache expires) | | Two concurrent calls | Both slow (locking) | | bash.exe -c "echo hello" | ~28 seconds | ## The Real Issue cygpath is just string manipulation - it doesn't need bash or MSYS2 runtime. The current call chain: ` Claude Code → bash.exe (MSYS2) → cygpath.exe (MSYS2) → return path ↑ ↑ 28s overhead (was 29s, now fixed) ` ## Recommended Fix ### Option 1: Call cygpath directly (quick fix) Instead of: ` bash.exe -c "cygpath -u '/path'" ` Call directly: ` cygpath.exe -u "/path" ` This eliminates bash.exe overhead but cygpath.exe still has MSYS2 startup cost. ### Option 2: Native path conversion (proper fix) Implement path conversion in Node.js natively: `javascript function unixToWindows(p) { // /c/Users/foo → C:\Users\foo return p.replace(/^\/([a-zA-Z])\//, '$1:\\').replace(/\//g, '\\'); } function windowsToUnix(p) { // C:\Users\foo → /c/Users/foo return p.replace(/^([a-zA-Z]):/, '/$1').replace(/\\/g, '/').toLowerCase(); } ` No shell spawning needed. Instant. ### Option 3: Cache results If shell calls are necessary, cache the results. Path mappings don't change during a session. ### Option 4: Use PowerShell instead of bash PowerShell is native Windows and has no MSYS2 overhead: `powershell # Much faster than bash.exe powershell -Command "echo hello" # ~200ms vs 28s ` ## Workaround Applied We created a Go-based cygpath.exe replacement without MSYS2 dependencies: - **Before**: 29 seconds (cold), 66ms (warm) - **After**: 25ms (always) However, this doesn't help because Claude Code wraps cygpath in bash.exe, which is still slow. ## Files - main.go - Fast cygpath replacement source - cygpath.exe - Compiled binary (installed to Git\usr\bin) - README.md - Installation/recovery instructions ## Test Commands `powershell # Test bash overhead Measure-Command { & "C:\Program Files\Git\bin\bash.exe" -c "echo hello" } # Test cygpath directly Measure-Command { & "C:\Program Files\Git\usr\bin\cygpath.exe" -w /tmp } # Test concurrent access (run in two PowerShell windows simultaneously) 1..30 | ForEach-Object { $t = Measure-Command { & "C:\Program Files\Git\usr\bin\cygpath.exe" -w /tmp } Write-Host "$_: $($t.TotalSeconds)s" } ``` ## Related Resources - Cygwin slowness on Windows (SuperUser) - Cygpath documentation ## Contact Report generated during debugging session with Claude Code (Opus 4.5).
caozhiyuan · 10 months ago

Measure-Command { & "C:\Program Files\Git\bin\bash.exe" -c "echo hello" } , in my windows TotalMilliseconds : 121.2469 . but claude code read file really very slow when need read multi files. @honix

caozhiyuan · 10 months ago

@honix i add CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\Git\usr\bin\bash.exe in env and C:\Program Files\Git\usr\bin in path , become a bit smoother

caozhiyuan · 9 months ago

@honix One FileRead call invoked cygpath -u over 20 times, causing extremely slow file reading.

honix · 9 months ago

It seems it much better in recent versions of Claude Code. The 2.1.6 (Claude Code) doesnt hangs file reads or something, it feels smooth now.

github-actions[bot] · 8 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.