claude-code - 💡(How to fix) Fix [BUG] claude crashes on WSL with ENOEXEC when reading Windows-side managed settings (wslInheritsWindowsSettings) [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#52350Fetched 2026-04-24 06:09:31
View on GitHub
Comments
1
Participants
2
Timeline
12
Reactions
0
Author
Timeline (top)
labeled ×5cross-referenced ×3subscribed ×2commented ×1

Error Message

Both execve calls fail with ENOEXEC, and the second failure is promoted to an unhandled exception that terminates the process.

Error Messages/Logs

0x... /* 42 vars /) = -1 ENOEXEC (Exec format error) 0x... / 42 vars */) = -1 ENOEXEC (Exec format error) ENOEXEC: unknown error, posix_spawn '/mnt/c/Windows/System32/reg.exe'

Root Cause

On WSL, claude crashes at startup with ENOEXEC from posix_spawn because it tries to invoke Windows reg.exe to read managed-policy settings from the Windows registry. The bundled Bun runtime cannot execute a PE binary via WSL's binfmt_misc interop, so the process dies before the UI starts. strace -f -e execve claude shows Claude Code attempts two registry reads during startup:

Fix Action

Fix / Workaround

Confirmed via strace -f -e execve claude that the failing spawn targets /mnt/c/Windows/System32/reg.exe for HKLM\SOFTWARE\Policies\ClaudeCode then HKCU\SOFTWARE\Policies\ClaudeCode, both with value name Settings. Workaround: adding the following to /etc/wsl.conf and running wsl --shutdown from Windows removes reg.exe from $PATH and lets claude start:

Code Example

[pid 898782] execve("/mnt/c/Windows/System32/reg.exe",
  ["/mnt/c/Windows/System32/reg.exe", "query",
   "HKLM\\SOFTWARE\\Policies\\ClaudeCode", "/v", "Settings"],
  0x... /* 42 vars */) = -1 ENOEXEC (Exec format error)
[pid 898782] +++ exited with 127 +++
[pid 898783] execve("/mnt/c/Windows/System32/reg.exe",
  ["/mnt/c/Windows/System32/reg.exe", "query",
   "HKCU\\SOFTWARE\\Policies\\ClaudeCode", "/v", "Settings"],
  0x... /* 42 vars */) = -1 ENOEXEC (Exec format error)
[pid 898783] +++ exited with 127 +++

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)

---

[interop]
appendWindowsPath = 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?

On WSL, claude crashes at startup with ENOEXEC from posix_spawn because it tries to invoke Windows reg.exe to read managed-policy settings from the Windows registry. The bundled Bun runtime cannot execute a PE binary via WSL's binfmt_misc interop, so the process dies before the UI starts. strace -f -e execve claude shows Claude Code attempts two registry reads during startup:

  • reg.exe query HKLM\SOFTWARE\Policies\ClaudeCode /v Settings
  • reg.exe query HKCU\SOFTWARE\Policies\ClaudeCode /v Settings

Both execve calls fail with ENOEXEC, and the second failure is promoted to an unhandled exception that terminates the process. Two issues seem to be stacked here:

When running as a Linux binary inside WSL, Claude Code probably shouldn't be querying the Windows registry at all. reg.exe is only found because WSL imports the Windows PATH by default (appendWindowsPath = true). The Linux-side managed-settings source (/etc/claude-code/managed-settings.json) is what ought to be consulted. Even if a registry read were intended, a failed spawn of reg.exe is not a fatal condition and should be caught so startup can proceed.

What Should Happen?

claude should start successfully under WSL. Ideally the Windows registry lookup is skipped entirely on Linux (including WSL), and at minimum any ENOEXEC / spawn failure from reg.exe should be caught so managed-settings discovery degrades gracefully.

Error Messages/Logs

[pid 898782] execve("/mnt/c/Windows/System32/reg.exe",
  ["/mnt/c/Windows/System32/reg.exe", "query",
   "HKLM\\SOFTWARE\\Policies\\ClaudeCode", "/v", "Settings"],
  0x... /* 42 vars */) = -1 ENOEXEC (Exec format error)
[pid 898782] +++ exited with 127 +++
[pid 898783] execve("/mnt/c/Windows/System32/reg.exe",
  ["/mnt/c/Windows/System32/reg.exe", "query",
   "HKCU\\SOFTWARE\\Policies\\ClaudeCode", "/v", "Settings"],
  0x... /* 42 vars */) = -1 ENOEXEC (Exec format error)
[pid 898783] +++ exited with 127 +++

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)

Steps to Reproduce

  1. On a WSL (Ubuntu) instance with default /etc/wsl.conf (i.e. appendWindowsPath = true, so /mnt/c/Windows/System32 is on $PATH and reg.exe is resolvable by name)
  2. Install Claude Code: npm install -g @anthropic-ai/claude-code
  3. In any directory, run claude
  4. The process crashes with the stack trace shown above before anything interactive appears

Confirmed via strace -f -e execve claude that the failing spawn targets /mnt/c/Windows/System32/reg.exe for HKLM\SOFTWARE\Policies\ClaudeCode then HKCU\SOFTWARE\Policies\ClaudeCode, both with value name Settings. Workaround: adding the following to /etc/wsl.conf and running wsl --shutdown from Windows removes reg.exe from $PATH and lets claude start:

[interop]
appendWindowsPath = false

This is undesirable for users who rely on invoking Windows tools from WSL by name.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.118 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

  • WSL Version: 2.4.11.0
  • Description: Ubuntu 24.04.4 LTS
  • Node.js: v24.1.0 (installed via asdf); the claude binary is a Bun-compiled standalone (Bun v1.3.13 Linux x64 baseline) despite being installed through npm
  • Binary path: ~/.asdf/installs/nodejs/24.1.0/bin/claude
  • Full strace -f -e execve claude log available on request

extent analysis

TL;DR

To fix the issue, modify the WSL configuration to prevent reg.exe from being executed by setting appendWindowsPath = false in /etc/wsl.conf, or catch the ENOEXEC error in the Claude Code application to allow it to start successfully under WSL.

Guidance

  • The issue arises because the Claude Code application attempts to query the Windows registry using reg.exe, which fails with ENOEXEC due to the Bun runtime's inability to execute PE binaries via WSL's binfmt_misc interop.
  • To resolve this, you can either modify the WSL configuration to exclude Windows paths from the system PATH or modify the Claude Code application to catch the ENOEXEC error and degrade gracefully.
  • Setting appendWindowsPath = false in /etc/wsl.conf and restarting WSL will prevent reg.exe from being executed, allowing Claude Code to start.
  • Alternatively, you can investigate modifying the Claude Code application to use the Linux-side managed-settings source (/etc/claude-code/managed-settings.json) instead of querying the Windows registry.

Example

No code snippet is provided as the issue is related to configuration and application behavior rather than a specific code error.

Notes

The provided workaround may not be desirable for users who rely on invoking Windows tools from WSL by name. A more robust solution would involve modifying the Claude Code application to handle the ENOEXEC error or use the Linux-side managed-settings source.

Recommendation

Apply the workaround by setting appendWindowsPath = false in /etc/wsl.conf and restarting WSL, as this provides a straightforward solution to the issue. However, it is recommended to investigate modifying the Claude Code application to handle the ENOEXEC error or use the Linux-side managed-settings source for a more robust and user-friendly solution.

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

claude-code - 💡(How to fix) Fix [BUG] claude crashes on WSL with ENOEXEC when reading Windows-side managed settings (wslInheritsWindowsSettings) [1 comments, 2 participants]