WSL: node.exe via WSL fails with EINVAL on uv_pipe_open
There are a few earlier reports on uv_pipe_open, but they seem to be about a “unknown system error” in linux node.
This has been happening in my old WSL for a few months now, at least, but I believe it was working as of CU. I wasn’t too concerned since I had some cruft built up in my setup, and I didn’t see any other reports, but it’s still happening with the new Windows Store Ubuntu install.
Not too concerned, since you can always have a cmd.exe window up, but it is a pain when doing a windows yarn install (linux yarn install doesn’t creating working windows bin stubs, but vice-versa does)
-
Your Windows build number: (Type
verat a Windows Command Prompt) Microsoft Windows [Version 10.0.16241.1001] -
What you’re doing and what’s happening: (Copy&paste specific commands and their output, or include screen shots)
Any attempt to run node.exe (I’m using v6.11.1) from WSL fails:
$ node.exe
net.js:145
this._handle.open(options.fd);
^
Error: EINVAL: invalid argument, uv_pipe_open
at Error (native)
at new Socket (net.js:145:18)
at process.getStdin [as stdin] (internal/process/stdio.js:70:19)
at startup (bootstrap_node.js:177:18)
at bootstrap_node.js:509:3
Very similar error if it doesn’t need to open stdin:
$ node.exe -p 123
net.js:145
this._handle.open(options.fd);
^
Error: EINVAL: invalid argument, uv_pipe_open
at Error (native)
at new Socket (net.js:145:18)
at createWritableStdioStream (internal/process/stdio.js:156:16)
at process.getStdout [as stdout] (internal/process/stdio.js:10:14)
at console.js:100:37
at NativeModule.compile (bootstrap_node.js:492:7)
at Function.NativeModule.require (bootstrap_node.js:433:18)
at get (bootstrap_node.js:254:34)
at evalScript (bootstrap_node.js:354:30)
at run (bootstrap_node.js:122:11)
Same issue when running cmd.exe (which works), then running node.exe.
- What’s wrong / what should be happening instead:
Should still work, obviously 🐱🐉
- Strace of the failing command, if applicable: (If
<cmd>is failing, then runstrace -o strace.txt -ff <cmd>, and post the strace.txt output here)
Pretty boring, since it’s interop:
execve("/mnt/c/Program Files/nodejs/node.exe", ["node.exe"], [/* 22 vars */]) = 0
brk(NULL) = 0x7fffea3ab000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb64fa0000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=19068, ...}) = 0
mmap(NULL, 19068, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbb64faa000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb64830000
mprotect(0x7fbb649f0000, 2097152, PROT_NONE) = 0
mmap(0x7fbb64bf0000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7fbb64bf0000
mmap(0x7fbb64bf6000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbb64bf6000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb64f90000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb64f80000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb64f70000
arch_prctl(ARCH_SET_FS, 0x7fbb64f80700) = 0
mprotect(0x7fbb64bf0000, 16384, PROT_READ) = 0
mprotect(0x7fbb6520b000, 4096, PROT_READ) = 0
mprotect(0x7fbb64e25000, 4096, PROT_READ) = 0
munmap(0x7fbb64faa000, 19068) = 0
getpid() = 9495
brk(NULL) = 0x7fffea3ab000
brk(0x7fffea3cc000) = 0x7fffea3cc000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1668976, ...}) = 0
mmap(NULL, 1668976, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbb64c8d000
close(3) = 0
getcwd("/mnt/c/code/splinter", 4096) = 21
open("/dev/lxssclient", O_RDWR) = 3
ioctl(3, _IOC(0, 0x00, 0x2f, 0x22), 0x7ffff189a7b0) = 0
open("/mnt/c/Program Files/nodejs/node.exe", O_RDONLY) = 5
ioctl(3, _IOC(0, 0x00, 0x3f, 0x22), 0x7ffff189a660) = 0
close(5) = 0
open("/mnt/c/code/splinter", O_RDONLY) = 5
ioctl(3, _IOC(0, 0x00, 0x3f, 0x22), 0x7ffff189a660) = 0
close(5) = 0
ioctl(4, _IOC(0, 0x00, 0x97, 0x22), 0x7ffff189a710) = 0
ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7ffff189a708) = 0
ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7ffff189a708) = 0
ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7ffff189a708) = 0
write(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0002\0\0\0\0\0\0\0"..., 171) = 171
read(4, "\0\0\0\0\0\0\0\0001\0\0\0\0\0\0\0", 16) = 16
ioctl(4, _IOC(0, 0x00, 0x9b, 0x22), 0x7ffff189a7a8) = 0
write(4, "\0\0\0\0\0\0\0\0001\0\0\0\0\0\0\0", 16) = 16
ioctl(5, _IOC(0, 0x00, 0xbf, 0x22), 0x7ffff189a7a0) = 0
close(3) = 0
close(4) = 0
close(5) = 0
exit_group(1) = ?
+++ exited with 1 +++
See our contributing instructions for assistance.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 18
- Comments: 36 (7 by maintainers)
Fixed in 17618.
@therealkenc - I’m currently working on a change that should fix this.
TL;DR Bash was picking up nvm-windows, which tried to use Node Windows binaries.
I upgraded to 17666.1000 and I was still seeing:
I thought that starting from fresh maybe would help. So I deleted everything related to nvm and node. After that, the nvm command still worked. That is how I found that bash was also picking up nvm-windows.
I uninstalled that and then installed regular nvm again. Everything worked from there.
Just executed
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
in a “Ubuntu 18.04.3 LTS” in WSL 2 at Windows 10 version 1909 (build 18363.657).
The issue persists.
I know the thread is closed, but I hope this helps someone in future. I am using WSL and for no obvious reason I got the same error:
I am using
nvmand just runningnvm use <your_node_version>solved the issue for me.hello, the solution for me was to uninstall nodejs.
sudo apt remove nodejsthen:sudo apt install wgetwget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bashsource ~/.profilelook at the current list of versions in nodejs
nvm ls-remoteInstall the required or desired version
nvm install 10.15.3And confirm that he used it
node -vconclusion
everything happens due to the bad installation of nodejs without the npm corresponding to the version
@abrioy Thanks for that function you’re amazing!
Some small changes:
There should be a semicolon at the end of the line before the last curly bracket. Also $@ will cause problems when you pass in more than one argument.
For example, calling foo() { cmd.exe /C “echo $@ 2>&1 < NUL | cat” } with foo a b c will result in:
No idea why this happens, but if you use $* to get command line arguments as a string instead of an array it works.
working function:
Here’s a quick and dirty solution based on @131 answer, for those of us who still have this issue:
npm() { cmd.exe /C "npm $@ 2>&1 < NUL | cat" }You can set it as an alias in your shell and have a mostly working npm in wsl.
From nodejs/stdio.js I’ll guess that WSL expose PIPEs file descriptor for stdin/stdout/stderr when spawning .exe, when they should have been forwarded as TTY/console (yet i guess, unix TTY & windows TTY interop is not an easy path).
For nodejs.exe, you can force STDIN, STDOUT & STDERR as real PIPEs so node_bootstrap (and your script) won’t crash.
node.exe foo.js > NUL 2>NUL < NUL[insert motivation picture for @benhillis here !]
@marchaos - Still working through some changes, no ETA yet but hoping to get this fixed soon.
@benhillis - Someone else at MSFT is feeling your pain. I thought I would try and be clever and make a point, but
node.exedoesn’t work with the new fangled native Windows 10 OpenSSH either. This is withsshdrunning on port 22 on the win32 side, and all the public key accoutrements. On the WSL side:So the question is, which team fixes it first? 😉
If it rains another weekend I am going to beat you to it, Ben. 😛
I don’t deserve all the credit, shout-out to @zadjii-msft for his hard work. We are working out a way to formalize this functionality into a set of APIs.