[BUG] ENOEXEC error when running Claude Code on WSL2 (Bun v1.3.13 regression)
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?
Root Cause
Bun v1.3.13 introduced a regression where it tries to call reg.exe (Windows registry tool) via posix_spawn from within WSL2. Since /mnt/c/Windows/System32/reg.exe is a Windows PE executable, the Linux kernel cannot execute it and returns ENOEXEC.
What Should Happen?
Claude should open the TUI
Error Messages/Logs
## Error
662 | var file = this.spawnfile = options.file, spawnargs;
663 | if (options.args === @undefined)
664 | spawnargs = this.spawnargs = [];
665 | else
666 | validateArray(options.args, "options.args"), spawnargs = this.spawnargs = options.args;
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)
Bun v1.3.13 (Linux x64 baseline)
Steps to Reproduce
Steps to Reproduce
- Install Bun v1.3.13 on WSL2
- Install Claude Code via
npm install -g @anthropic-ai/claude-code - Run
claude— crashes immediately with the error above
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
Workarounds attempted:
Global Bun Downgrade: Failed (Claude uses its own bundled v1.3.13).
PATH Mocking: Failed (The binary seems to call the absolute path /mnt/c/Windows/System32/reg.exe).
WSL Interop manual fix: echo ':WSLInterop:M::MZ::/init:PF' | sudo tee /proc/sys/fs/binfmt_misc/register (Only works if the kernel allows re-registration).
Recommended Fix for Users:
The only reliable way to bypass this until a new version is released with Bun v1.3.14+ is to force the use of a version that doesn't include the faulty runtime or use npx with an older tag:
Bash
Install a previous stable version that uses a different Bun/Node runtime
npm install -g @anthropic-ai/claude-code@0.2.23
All workaounds and Fixes were recommended and implemented by Gemini as at the moment Claude was dead :)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗