[BUG] Hard crash at startup on WSL2 when binfmt_misc has no WSLInterop entry (ENOEXEC spawning reg.exe)

Resolved 💬 3 comments Opened Apr 23, 2026 by stefanelli Closed Jun 12, 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?

### 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

  1. 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_

View original on GitHub ↗

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