mintty / wsltty

Mintty as a terminal for Bash on Ubuntu on Windows / WSL
Other
3.12k stars 104 forks source link

Backend error when launching wsltty 3.0.5 for WSL 2 distro #193

Closed tetov closed 5 years ago

tetov commented 5 years ago

Hi!

Thanks for all the hard work, I've really missed wsltty since I switched to WSL2.

However, when I try to run wsltty through the newly generated shortcut (with -h always added) I get this output:

/bin/hvpty: Exit 1.
note: backend error output: /mnt/c/Users/a/AppData/Local/wsltty/bin/hvpty-backend: unrecognized option: envAPPDATA=C:\Users\a\AppData\Roaming
Try '/mnt/c/Users/a/AppData/Local/wsltty/bin/hvpty-backend --help' for more information.

I'm realize that this might not have anything to do with wsltty, but instead with Biswa96/wslbridge2 but since I can run hvpty.exe fine on it's own I wanted to check here first.

I can't find where the env argument is passed, I would like to try without since this PR on the wslbridge2 repo seems to indicate that something related to arguments passed to hvpty is buggy.

EDIT: %LOCALAPPDATA%\wsltty\bin\mintty.exe --configdir="%APPDATA%\wsltty" %LOCALAPPDATA%\wsltty\bin\hvpty.exe -W '$HOME' -l works for some reason, except I can't close the window (as described in this issue).

mintty commented 5 years ago

@Biswa96, I don't see how this is passed to the backend at all or why the env is not separated. Mysterious, however, is how this can happen to one users but not elsewhere...

tetov commented 5 years ago

I was surprised as well to not find other people reporting the same issue..

Before you ask, I have done a complete uninstall including %APPDATA%/wsltty and I have no mintty folder in %APPDATA% or in home folder.

Biswa96 commented 5 years ago

Yes, it was my fault. Apology for the inconvenience 🙇 The PR will fix the environment variable issue. To close window, you can press Ctrl+D twice or enter exit command. I'll fix it as soon as possible.

tetov commented 5 years ago

@Biswa96 No need to apologize! So happy to get to use wsltty with WSL 2. :)

mintty commented 5 years ago

@Biswa96, I'm confused; you fixed a missing separator, but why was it not missing for me and others?

Biswa96 commented 5 years ago

I fixed those two issues. The test binaries can be downloaded from Appveyor project VS2017 artifacts.

dxhisboy commented 5 years ago

@Biswa96, I'm confused; you fixed a missing separator, but why was it not missing for me and others?

That is because hvpty and wslbridge used different method to build the command string. Also, the argument passing from frontend to backend is not so stable, for example, when you pass --wsldir=~, then /bin/sh will automatically expand ~ to home directory, but if you pass --wsldir='~', then /bin/sh will leave ~ unexpanded, and chdir in hvpty-backend also do not expand the ~, then it will fail to process the ~, while wslbridge has a resolveCwd function to expand such thing. Now I rewrite the path processing in hvpty-backend using wordexp and it can even process parameters with *, ? or environment variables in --wsldir. Another issue is not only the problem on separator, it is also on the argument itself. When sh call a program with ./a.out --env a=b, then argv[1] == "--env" and argv[2] == "a=b", that can be perfectly handled by getopt_long, but in the old hvpty, it passed something like ./a.out '--env a=b' to sh, causing argv[1] == "--env a=b", and getopt_long think it is only one argument so the argument parsing will fail.

mintty commented 5 years ago

Tried to integrate wslbridge2 v0.4 with wsltty. WSL V2 invocations fail with note: backend error output: /mnt/c/Users/towo/AppData/Local/wsltty/bin/hvpty-backend: line 1: syntax error: unexpected word (expecting ")") if started from the wsltty-installed mintty. From cygwin, however, it works fine. I'm puzzled.

Biswa96 commented 5 years ago

Can you share the installer that you've made?

mintty commented 5 years ago

wsltty-3.0.5.2-install.zip

Biswa96 commented 5 years ago

Did you compile the hvpty-backend with make RELEASE=1? If I replace it with compiling my own it works well. Try to use musl libc.

mintty commented 5 years ago

I compiled it in Alpine. Which distro do you use?

Biswa96 commented 5 years ago

Me too, Alpine. The size of hvpty-backend is 159 KB with musl but your installer has 1.52 MB.

mintty commented 5 years ago

GRMBL! Works now. There is a problem in the build process: when invoking the backend build with cd wslbridge2-$(wslbridgever); cmd /C wsl -d Alpine make RELEASE=1 this would not terminate but finally stall until I press Enter. No idea why. I tried to workaround this with cd wslbridge2-$(wslbridgever); cmd /C wsl -d Alpine make RELEASE=1 & (sleep 8; echo built) which kind of works, except the backend is not copied properly if the build takes too long... (Trying a more proper workaround that looks for the appearance of the files.)

dxhisboy commented 5 years ago

@mintty You can use wsl -e xxx < /dev/null to make it exit after command finished. Actually wsl.exe was waiting for some stdin, rawpty can also solve this.

mintty commented 5 years ago

Mine, the wsltty makefile. Thanks for /dev/null.

tetov commented 5 years ago

I fixed those two issues. The test binaries can be downloaded from Appveyor project VS2017 artifacts.

The shortcuts works now for me after I replaced the binaries. The only error I get is chdir: No such file or directory which I think must be an error in parsing the argument -~ in the shortcut.

mintty commented 5 years ago

Released 3.0.6.

mintty commented 5 years ago

Please recheck the chdir issue.