[Bug] Child process PATH inheritance fails on Windows with Cygwin

Resolved 💬 3 comments Opened Jan 28, 2026 by johnholliday Closed Feb 1, 2026

Bug Description

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?

Claude Code fails when executing the /init command with a cygpath error, even though cygpath is in the system PATH and executes successfully from the same terminal. This indicates Claude Code is spawning a child process that does not inherit the system PATH correctly.

Key observation: Running cygpath -u 'c:\users\john\dev\test-ide' manually in the same terminal works perfectly and returns /cygdrive/c/users/john/dev/test-ide. The issue is specifically how Claude Code spawns its child process.

Error Message

ERROR  Command failed: cygpath -u 'c:\users\john\dev\test-ide'
node:child_process:1010:22
- genericNodeError (node:child_process:1010:22)
- checkExecSyncError (node:child_process:470:27)
- execSync (node:child_process:278:31)
- SK (B:/~BUN/root/claude.exe:54:3338)
- rS (B:/~BUN/root/claude.exe:71:418)
- yAf (B:/~BUN/root/claude.exe:5166:25442)
- qg (B:/~BUN/root/claude.exe:5166:28493)
- <anonymous> (B:/~BUN/root/claude.exe:5166:28261)
- some (native:1:11)
- <anonymous> (B:/~BUN/root/claude.exe:5166:28253)

Environment Info

  • Platform: Windows 11
  • Terminal: VS Code integrated PowerShell terminal
  • Claude Code Version: Native Windows (claude.exe via Bun)
  • Shell: PowerShell
  • Cygwin: Installed at C:\cygwin64, bin directory IS in system PATH

Steps to Reproduce

  1. Install Cygwin on Windows with C:\cygwin64\bin in system PATH
  2. Verify cygpath works: cygpath -u 'c:\users\john\dev\test-ide' → returns valid path
  3. Open VS Code with PowerShell as integrated terminal
  4. Navigate to project directory
  5. Run claude
  6. Select "Yes, I trust this folder"
  7. Run /init command
  8. Observe cygpath error

Expected Behavior

Since cygpath is available in PATH and works when called directly, Claude Code's child process should inherit PATH and successfully execute the same command.

Attempted Workarounds (All Failed)

  • Adding C:\cygwin64\bin to system PATH — same error
  • Removing C:\cygwin64\bin from system PATH — same error
  • Removing cygpath.exe entirely — same error (still attempts to call it)
  • Running from native PowerShell outside VS Code — same error
  • Checking VS Code terminal environment settings — no Cygwin-specific overrides

Root Cause Hypothesis

Claude Code's execSync call appears to spawn a shell that:

  1. Does not inherit the Windows system PATH, OR
  2. Spawns a different shell (e.g., /usr/bin/bash) that doesn't have Cygwin in its PATH, OR
  3. Has hardcoded shell detection that selects the wrong execution context

The error trace shows the command is being passed to some shell that cannot find cygpath, despite it being available in the parent process environment.

Related Issues

  • #3923 — Bash Command Execution Fails on Windows with Cygpath Not Found
  • #7528 — Critical Bug - Claude Code forces non-existent cygpath on Windows
  • #8440 — Claude Code CLI crashes on Windows with "cygpath: command not found"
  • #9182 — Claude Code is trying to call cygpath internally but failing
  • #9883 — Claude Code Bash tool incompatible with MSYS/Git Bash on Windows

Suggested Fix

  1. When spawning child processes, ensure PATH inheritance from the parent environment
  2. If calling cygpath, use the full path or verify availability before attempting execution
  3. Consider using Node's native path module for Windows path conversion instead of relying on external tools

Environment Info

  • Platform: win32
  • Terminal: windows-terminal
  • Version: 2.1.22
  • Feedback ID: c41e4f72-a92f-418c-8cd4-d73ae45c2261

Errors

[{"error":"Error: ENOENT: no such file or directory, scandir 'C:\\ProgramData\\ClaudeCode\\.claude\\skills'\n    at readdirSync (unknown)\n    at <anonymous> (B:/~BUN/root/claude.exe:12:2063)\n    at oX (B:/~BUN/root/claude.exe:11:35454)\n    at readdirSync (B:/~BUN/root/claude.exe:12:2024)\n    at H6$ (B:/~BUN/root/claude.exe:1756:380)\n    at H6$ (B:/~BUN/root/claude.exe:1756:1350)\n    at <anonymous> (B:/~BUN/root/claude.exe:1756:4670)\n    at <anonymous> (B:/~BUN/root/claude.exe:1756:5401)\n    at A (B:/~BUN/root/claude.exe:11:7259)\n    at pxE (B:/~BUN/root/claude.exe:4818:4342)","timestamp":"2026-01-28T18:01:44.486Z"},{"error":"Error: ENOENT: no such file or directory, scandir 'C:\\Users\\John\\.claude\\skills'\n    at readdirSync (unknown)\n    at <anonymous> (B:/~BUN/root/claude.exe:12:2063)\n    at oX (B:/~BUN/root/claude.exe:11:35454)\n    at readdirSync (B:/~BUN/root/claude.exe:12:2024)\n    at H6$ (B:/~BUN/root/claude.exe:1756:380)\n    at H6$…

Note: Content was truncated.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗