claude-code - 💡(How to fix) Fix [BUG] Hard crash at startup on WSL2 when binfmt_misc has no WSLInterop entry (ENOEXEC spawning reg.exe) [1 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#52318Fetched 2026-04-24 06:10:21
View on GitHub
Comments
1
Participants
2
Timeline
11
Reactions
3
Timeline (top)
cross-referenced ×4labeled ×4subscribed ×2commented ×1

Error Message

the probe. That isn't discoverable from the error message, though.

Error Messages/Logs

bash: /mnt/c/Windows/System32/reg.exe: cannot execute binary file: Exec format error ENOEXEC: unknown error, posix_spawn '/mnt/c/Windows/System32/reg.exe'

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?

Environment

  • Claude Code: 2.1.118
  • Runtime: Bun v1.3.13 (Linux x64 baseline, bundled with the CLI)
  • OS: WSL2 on Windows, Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64
  • /etc/wsl.conf has systemd=true

Summary

Claude Code crashes at startup when it tries to probe for installed IDEs by executing /mnt/c/Windows/System32/reg.exe. If WSL binfmt_misc has no WSLInterop registration, posix_spawn returns ENOEXEC and the CLI aborts before doing anything — it is unusable.

Notes

  • The path /mnt/c/Windows/System32/reg.exe appears to be hardcoded in cli.js — removing /mnt/c/... entries from PATH does not prevent the crash.
  • CLAUDE_CODE_AUTO_CONNECT_IDE=false works around the crash by skipping the probe. That isn't discoverable from the error message, though.
  • The underlying WSL fix is sudo systemctl mask systemd-binfmt.service then wsl --shutdown. But the CLI shouldn't need the user to fix their kernel config just to start.

What Should Happen?

Suggested fix

Wrap the reg.exe / IDE-probe execFile call in a try/catch (or .catch(() => undefined) on the Promise) so that ENOEXEC, ENOENT, and other spawn failures degrade gracefully to "no IDE detected" instead of killing the process.

Error Messages/Logs

Steps to Reproduce

Reproduction

  1. On WSL2 with systemd=true in /etc/wsl.conf, systemd-binfmt.service clears the WSLInterop entry at boot. Confirm the absence:

    $ ls /proc/sys/fs/binfmt_misc/ | grep -i wsl (no output) $ /mnt/c/Windows/System32/reg.exe /? bash: /mnt/c/Windows/System32/reg.exe: cannot execute binary file: Exec format error

  2. Run claude.

Actual

662 | var file = this.spawnfile = options.file, spawnargs; ... 667 | if (this.#handle = Bun.spawn({ ^ ENOEXEC: unknown error, posix_spawn '/mnt/c/Windows/System32/reg.exe' path: "/mnt/c/Windows/System32/reg.exe", syscall: "posix_spawn", errno: -8, code: "ENOEXEC"

at spawn (node:child_process:667:35)
at spawn (node:child_process:14:39)
at execFile (node:child_process:59:20)
at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:188:1452)
at new Promise (1:11)
at gl6 (/$bunfs/root/src/entrypoints/cli.js:188:1422)
at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:188:1602)
at $W$ (/$bunfs/root/src/entrypoints/cli.js:188:1822)
at Ql6 (/$bunfs/root/src/entrypoints/cli.js:188:1861)

Bun v1.3.13 (Linux x64 baseline)

The CLI exits non-zero; REPL never starts.

Expected

IDE auto-detection is a best-effort feature. A failed probe should be caught and logged (or silently skipped), not abort the entire CLI. Whatever the WSL environment does, claude should still launch.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.118

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

No response

extent analysis

TL;DR

The most likely fix is to wrap the reg.exe / IDE-probe execFile call in a try/catch block to handle ENOEXEC and other spawn failures.

Guidance

  • The issue is caused by the hardcoded path to reg.exe and the lack of WSLInterop registration in binfmt_misc, leading to an ENOEXEC error when trying to spawn the process.
  • To verify the issue, check if the WSLInterop entry is present in /proc/sys/fs/binfmt_misc/ and try running reg.exe directly.
  • A temporary workaround is to set CLAUDE_CODE_AUTO_CONNECT_IDE=false to skip the IDE probe.
  • To fix the issue, modify the cli.js file to catch and handle spawn failures, allowing the CLI to launch even if the IDE probe fails.

Example

try {
  // execFile call to reg.exe
} catch (error) {
  // Handle error and continue launching the CLI
  console.log("IDE probe failed, continuing...");
}

Notes

The fix requires modifying the cli.js file, which may not be feasible for all users. Additionally, the underlying WSL issue can be fixed by running sudo systemctl mask systemd-binfmt.service and then wsl --shutdown, but this is not a solution for the CLI itself.

Recommendation

Apply the workaround by setting CLAUDE_CODE_AUTO_CONNECT_IDE=false until a fixed version of the CLI is available. This allows the CLI to launch while skipping the IDE probe, providing a temporary solution until the issue is fully resolved.

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