xilun / cbwin

Launch Windows programs from "Bash on Ubuntu on Windows" (WSL)
Other
327 stars 25 forks source link

Not work inside zsh #32

Closed lkytal closed 7 years ago

lkytal commented 7 years ago

Works directly in bash. However, after I launch zsh inside bash, wcmd errors ERR MSG:

wcmd: OUTBASH_PORT environment variable not set, and could not read /home/lky/.config/cbwin/outbash_port wcmd: can't translate a WSL VolFs path to a Win32 one [1] 132 killed wcmd ver

wsl

goreliu commented 7 years ago

$HOME of root is /root, not /home/lky, so wcmd can't read outbash_port file. And /root is not in DrvFs (/mnt/x), see also https://github.com/xilun/cbwin/issues/20.

fpqc commented 7 years ago

Don't do sudo zsh (why are you running zsh and therefore its child wcmd as root?!)

That's only part of the problem.

You would also need to do wcmd : cmd

The : tells wcmd, wstart, and wrun to launch in your %userprofile% in Windows. Without that parameter, the cbwin utilities will attempt path translation of the "start in" directory, which matters for various programs.

For example, if the pwd in your linux shell (bash, zsh, FiSH, csh, tcsh, whatever) is /mnt/c/Windows/System32, running wcmd cmd would launch cmd in C:\Windows\System32

lkytal commented 7 years ago

Thanks for your reply. The point is that wcmd won't work under root, if I have a xxx.sh script need to run as root, it could not use wcmd.

fpqc commented 7 years ago

@lkytal Ummmm, I don't think there is a reason why you would ever need to run a wcmd script with Linux root.

goreliu commented 7 years ago

wcmd is not used to run xxx.sh (but xx.exe/xx.bat), and there is no root user in Windows, this root user only works in WSL.

fpqc commented 7 years ago

@goreliu Jinx!

xilun commented 7 years ago

It's unfortunate wcmd does not work under root reached with a sudo (at least not without extra configuration), but I'm not sure it is worth to invest much energy in that. @lkytal what is more precisely your scenario where running wcmd as root would be important for you?

As a work-around, you can try to launch outbash with the --outbash-session option, or to elevate with su instead of sudo.

lkytal commented 7 years ago

@xilun Elevate with su does work, Thanks. Running wcmd with sudo is not that important to me, but I do feel strange that wcmd behaves differently between root and normal users. Better support towards sudo may make this little interesting project better :smile:

poma commented 7 years ago

Here's how to fix it:

  1. Run outbash.exe --outbash-session so that it will write outbash_port in your home dir
  2. Run sudo ln -s /home/lky/.config /root/.config to pass outbash_port file to root user
tomsihap commented 7 years ago

Thanks a lot poma, this works !

fpqc commented 7 years ago

@tomsihap Not sure if you're aware, but this feature was adopted into the driver by Microsoft since 14951, not that Xilun's work isn't excellent!

xilun commented 7 years ago

I'd actually advise testing/using MS interop if you can (that is: for now on Insider builds, and don't need any feature/behavior they don't provide yet). Actually they can do things we cannot without access to their implementation, or at least not with extreme difficulty and hacks. For example stdin forwarding just can't be perfect with an extra layer out of the implementation - like I'm forced to do; while once completely debugged their interop capable pipes will be just fine for that. I don't envision maintaining cbwin forever. (But I'll maintain it at least for people using stable versions of Windows.)

poma commented 7 years ago

When this feature is supposed to be released in a stable windows build? Does MS implementation work with interactive apps? (for example wrun ssh ... doesn't work in cbwin)

xilun commented 7 years ago

The next stable Windows release should be in spring 2017. I can't speak for the MS team, but I think it is likely than interactive apps then work better with their interop and maybe some console updates, than they do on the Anniversary Update with cbwin. For info I've started to play with console modes a little in cbwin (in a separate branch), but for now I did not found anything good enough when running on the Anniversary Update...