nodejs not working, exec format error
Windows Version
Microsoft Windows [Version 10.0.26100.2454]
WSL Version
2.3.26.0
Are you using WSL 1 or WSL 2?
- [ ] WSL 2
- [x] WSL 1
Kernel Version
4.4.0-26100-Microsoft
Distro Version
Ubuntu 22.04
Other Software
nvm 0.39.7 node 23.3.0
Repro Steps
- Install nvm from https://github.com/nvm-sh/nvm
- Run
nvm install v23.3.0 - run
node.
Expected Behavior
Node runs without errors.
Actual Behavior
Diagnostic Logs
https://github.com/microsoft/WSL/issues/8151#issuecomment-2529656728
The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.
Diagnostic information
Detected appx version: 2.3.26.0
Found no WSL traces in the logs
Diagnostic information
Detected appx version: 2.3.26.0
Detected user visible error: Wsl/Service/CreateInstance/0xd00002fe
OK. Looks like our elf parser doesn't like that one of the elf program headers has an alignment that doesn't match the other program header alignments. We're probably being too strict here...
Still unfixed on WSL version: 2.4.10.0 pre-release
would be nice to be fixed this for WSL1, there are cases where people would like to use WSL1 instead of WSL2
Indeed this would be great to get fixed! WSL1 still has many advantages for me in most situations.
Just want to chime in that yes, this is still impacting WSL 1 users. I just got bitten by this when cursor CLI auto-updated itself and pulled in a binary with this problem.
https://forum.cursor.com/t/newest-cursor-cli-has-broken-node-binary-on-wsl-exec-format-error/135913/4
I have found a way to artificially produce misaligned elfs by using llvm bolt post-link optimizer.
@benhillis Any news?
The same here. For some reason, I have to use WSL1. Node.js v24 has become active LTS, but I'm forced to stay on v22.
I have been using this script to patch node executable.
Thanks for this script, it works.But make sure pyelftools should be installed before.
ivan@wangyifan101:~> sudo xbps-install python3-pyelftools
Name Action Version New version Download size
python3-pyelftools install - 0.32_2 152KB
Size to download: 152KB
Size required on disk: 714KB
Space available on disk: 61GB
Do you want to continue? [Y/n]
[*] Downloading packages
python3-pyelftools-0.32_2.x86_64.xbps.sig2: 512B [avg rate: 4505KB/s]
python3-pyelftools-0.32_2.x86_64.xbps: 152KB [avg rate: 1768KB/s]
python3-pyelftools-0.32_2: verifying RSA signature...
[*] Collecting package files
python3-pyelftools-0.32_2: collecting files...
[*] Unpacking packages
python3-pyelftools-0.32_2: unpacking ...
python3-pyelftools-0.32_2: registered 'pyelftools' alternatives group
Creating 'pyelftools' alternatives group symlink: readelf.py -> /usr/bin/readelf.py3
[*] Configuring unpacked packages
python3-pyelftools-0.32_2: configuring ...
Byte-compiling python3.13 code for module elftools...
Updating ldconfig(8) cache...
python3-pyelftools-0.32_2: installed successfully.
1 downloaded, 1 installed, 0 updated, 1 configured, 0 removed, 0 on hold.
ivan@wangyifan101:~> sudo python3 wsl-fix-exec-format-error.sh.txt /usr/sbin/node
Backing up /usr/sbin/node to /usr/sbin/node.bak
Fixing /usr/sbin/node....
Changing alignment of program header 3 from 8192 to 4096
Changing alignment of program header 4 from 2097152 to 4096
Success
ivan@wangyifan101:~> node
Welcome to Node.js v22.15.0.
Type ".help" for more information.
>
ivan@wangyifan101:~>