nullpo-head / wsl-distrod

Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability.
MIT License
1.9k stars 91 forks source link

Option 2's `dstros enable --start-on-windows-boot` seems to require restarting WSL2 #5

Closed tomykaira closed 2 years ago

tomykaira commented 2 years ago

I followed the steps in Option 2 of README.

Step 1, downloading and installing scripts succeeded.

In step 2, I got this error.

[Distrod][WARN] whoami.exe had an error:
[Distrod][ERROR] Failed to enable the autostart on Windows boot.

Caused by:
    wslpath -w '/tmp/.tmpTQ234D' exited with error. stderr: /bin/wslpath: /tmp/.tmpTQ234D: Invalid argument

I checked whoami.exe and wslpath, and I found these commands do not work with sudo.

> /mnt/c/Windows/System32/whoami.exe
desktop-xxxxxx\tomyk
~
> sudo /mnt/c/Windows/System32/whoami.exe
((no output with exit status code 255))
> wslpath -w /tmp/.tmpTQ234D
\\wsl.localhost\Ubuntu\tmp\.tmpTQ234D
~
> sudo wslpath -w /tmp/.tmpTQ234D
wslpath: /tmp/.tmpTQ234D: Invalid argument

This is fixed by running /opt/distrod/bin/distrod enable, wsl --termiante Ubuntu, and wsl zsh, then run /opt/distrod/bin/distrod enable --start-on-windows-boot again. Here these commands return the same results with and without sudo.

I suggest to put instructions to restart WSL2 for --start-on-windows-boot if it fails.

nullpo-head commented 2 years ago

oops, thanks for the catch again! Maybe I'll fix the doc with sudo -E.

nullpo-head commented 2 years ago

Unfortunately, this didn't reproduce in my environment. In general, sudo should not affect .exe interop. Perhaps you once enabled distrod by distrod enable and disabled it after it? In that case, this might happen.

tomykaira commented 2 years ago

Sorry for late response.

Perhaps you once enabled distrod by distrod enable and disabled it after it? In that case, this might happen.

I forgot the steps I took, but this was possible. Thank you for checking.