Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to run windows command from wsl2 #6588

Closed
stupidloud opened this issue Feb 25, 2021 · 6 comments
Closed

unable to run windows command from wsl2 #6588

stupidloud opened this issue Feb 25, 2021 · 6 comments

Comments

@stupidloud
Copy link

image

image

$PATH is right, wslinterop is enabled,
only exit code 1 is returned when I tried to run any windows exe

long time ago I had done a release upgrade from ubuntu-18 to ubuntu-20 inside wsl, but I am not sure if it's which cause this issue.

I tried to install fresh ubuntu-20/debian instances from MicrosoftStore, and both of them worked.

Dose anyone know why?

@therealkenc
Copy link
Collaborator

If you like you can post a link to a gist of the output from strace -f -o notepad.strace notepad.exe, as well as the missing Windows build version and cat /proc/version output from the template, as well as wsl.exe -l -v. The trace might show something glaring, but it is a long shot. Given that the problem does not manifest on a fresh install, there is no easy way (that I can think of anyway) to identify what might be different between the userland in your distro that fails and the distos that does not fail. Wild ass guess, post the output of `env | grep WSL_" on the distro that fails.

@stupidloud
Copy link
Author

Thanks for the reply, here is the info

https://gist.github.com/klever1988/0997193a25380c427b56bbbd8d7bef25

image

@ghost ghost removed the needs-author-feedback label Feb 25, 2021
@therealkenc
Copy link
Collaborator

Thanks for the strace log, it does show a fail:

8325  access("/run/WSL/8322_interop", F_OK) = -1 ENOENT (No such file or directory)
8325  open("/proc/8322/stat", O_RDONLY) = 5
8325  readv(5, [{iov_base="", iov_len=0}, {iov_base="8322 (strace) S 8 8322 8 34816 8"..., iov_len=1024}], 2) = 315
8325  close(5)                          = 0
8325  access("/run/WSL/8_interop", F_OK) = -1 ENOENT (No such file or directory)
8325  open("/proc/8/stat", O_RDONLY)    = 5
8325  readv(5, [{iov_base="", iov_len=0}, {iov_base="8 (bash) S 7 8 8 34816 8322 4210"..., iov_len=1024}], 2) = 321
8325  close(5)                          = 0
8325  access("/run/WSL/7_interop", F_OK) = -1 ENOENT (No such file or directory)
8325  open("/proc/7/stat", O_RDONLY)    = 5
8325  readv(5, [{iov_base="", iov_len=0}, {iov_base="7 (init) S 6 6 6 0 -1 4210752 14"..., iov_len=1024}], 2) = 167
8325  close(5)                          = 0
8325  access("/run/WSL/6_interop", F_OK) = -1 ENOENT (No such file or directory)

On WSL2, you should have WSL_INTEROP assigned to a socket in /run/WSL. On your working ("fresh") WSL2 distros, it will look something like:

image

On your Ubuntu distro, the WSL_INTEROP environment variable is not set. I can't tell you why, but you might be able to differentiate between it not getting set by /init and it (somehow) getting clobbered from inside the Ubuntu distro by trying:

image

What it should be set to is the highest PID /init from within the distro. Like:

image

You can set the variable to /run/WSL/NN_interop by hand as an experiment, which will probably get interop running (fleetingly). But the question remains why it is not set (or gets clobbered) in the first instance.

@DHowett
Copy link
Member

DHowett commented Feb 26, 2021

Have you followed one of the unrecommended guides on the internet for using “systemd” or “systemd-nspawn” inside WSL? This can cause trouble with the initial WSL environment being discarded.

@therealkenc
Copy link
Collaborator

Yeah, this. Thanks Dustin.

@stupidloud
Copy link
Author

Thanks.

image
image

There is no values to set variables, I think I have to destroy this instance...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants