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

docker-for-win: support PowerShell #157

Closed
eine opened this issue May 14, 2019 · 12 comments
Closed

docker-for-win: support PowerShell #157

eine opened this issue May 14, 2019 · 12 comments

Comments

@eine
Copy link
Contributor

eine commented May 14, 2019

Ref #148.

@phil294:
Concerning my idea of a docker-x11docker-image: Yes, I know, it would not help much: a simple batch script could achieve the same thing. However, there is no such batch script right now and I did not know there were any plans on doing so.

Since x11docker is itself a single bash script, adapting it to a batch script would imply rewriting almost the full project. Furthermore, x11docker relies on several tools that are normally found on Linux/Bash contexts, so I don't think it is a matter of syntax only.

@phil294:
With no batch script available and x11docker containerized, Windows users could be spared to install msys2 or cygwin. Feel free to ignore this paragraph, I should have opened a seperate issue.

This is a specific requirement, and we might be able to work around it. It is currently possible to execute bash from PowerShell, and it seems that the integration will improve in upcoming versions: https://www.youtube.com/watch?v=lwhMThePdIo.

So, it might be possible to use x11docker from PowerShell with VcXsrv, without requiring neither cygwin nor msys2. Cygwin would still be required in order to use --xwin.

I just tried the following:

PS C:\Users\username> bash
username@host:/mnt/c/Users/username$ export PATH=$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin/
username@host:/mnt/c/Users/username$ cd /mnt/c/Program\ Files/Docker/Docker/resources/bin/
username@host:/mnt/c/Program\ Files/Docker/Docker/resources/bin/$ ln -s docker.exe docker
username@host:/mnt/c/Program\ Files/Docker/Docker/resources/bin/$ cd /mnt/c/Users/username
username@host:/mnt/c/Users/username$ curl -fsSL https://raw.githubusercontent.com/mviereck/x11docker/master/x11docker | bash -s -- --clipboard --gpu x11docker/check
mkdir: cannot create directory /c: Permission denied

x11docker ERROR: Could not create cache folder
  /c/Users/eine/x11docker/cache

  Type 'x11docker --help' for usage information
  Debug options: '--verbose' (full log) or '--debug' (log excerpt).
  Logfile will be:
  Please report issues at https://github.com/mviereck/x11docker
@mviereck
Copy link
Owner

I did a test in Powershell, too. It works here.
However, a different cache folder is created, the right one is /mnt/c/Users/.... I am not sure why /mnt is missing in your case.

x11docker itself checks uname -r. If it contains Microsoft, it configures itself for WSL.

PS C:\Users\User\Downloads> bash -c 'uname -r'
4.4.0-17134-Microsoft

Can you check bash -c 'uname -r' in Powershell, please?

@eine
Copy link
Contributor Author

eine commented May 19, 2019

Can you check bash -c 'uname -r' in Powershell, please?

With 'Windows PowerShell' or 'Windows PowerShell ISE':

PS C:\Users\username> bash -c 'uname -r'
4.4.0-17134-Microsoft

With 'Windows PowerShell (x86)' or 'Windows PowerShell ISE (x86)':

PS C:\Users\username> bash -c 'uname -r'
3.0.6-338.x86_64

With 'Debian GNU/Linux':

username@DESKTOP-E1ER43H:~$ uname -r
4.4.0-17134-Microsoft

@mviereck
Copy link
Owner

Thanks.
So x11docker's check fails in 'Windows PowerShell ISE (x86)'. Maybe it should check PATH instead (or afterwards) for something like /Windows/System32.

I would expect that x11docker will already work on your system in 'Windows PowerShell' or 'Windows PowerShell ISE'. I did my own test run in just 'Powershell'.

@eine
Copy link
Contributor Author

eine commented May 19, 2019

The error reported in the first comment corresponds to 'Windows PowerShell'. I get the same result with either of them.

EDIT

'Windows PowerShell':

PS C:\Users\eine> bash -c 'ls -la /'
total 88
drwxr-xr-x  1 root root   512 Jan 20 03:46 .
drwxr-xr-x  1 root root   512 Jan 20 03:46 ..
drwxr-xr-x  1 root root   512 Feb  4 15:36 bin
drwxr-xr-x  1 root root   512 Oct 20  2018 boot
drwxr-xr-x  1 root root   512 May 20 00:15 dev
drwxr-xr-x  1 root root   512 May 13 22:14 etc
drwxr-xr-x  1 root root   512 Jan 20 03:47 home
-rwxr-xr-x  1 root root 87944 Jan  1  1970 init
drwxr-xr-x  1 root root   512 Feb  4 15:37 lib
drwxr-xr-x  1 root root   512 Nov 19 22:58 lib64
drwxr-xr-x  1 root root   512 Nov 19 22:57 media
drwxr-xr-x  1 root root   512 Jan 20 03:46 mnt
drwxr-xr-x  1 root root   512 Nov 19 22:57 opt
dr-xr-xr-x  8 root root     0 May 20 00:15 proc
drwx------  1 root root   512 Nov 19 22:57 root
drwxr-xr-x  1 root root   512 May 20 00:15 run
drwxr-xr-x  1 root root   512 Nov 19 22:58 sbin
drwxr-xr-x  1 root root   512 Nov 19 22:57 srv
dr-xr-xr-x 12 root root     0 May 20 00:15 sys
drwxrwxrwt  1 root root   512 May 20 00:13 tmp
drwxr-xr-x  1 root root   512 Nov 19 22:57 usr
drwxr-xr-x  1 root root   512 Nov 19 22:57 var

'Windows PowerShell (x86)':

PS C:\Users\eine> bash -c 'ls -la /'
total 29379
drwxr-xr-x  1 eine None        0 Jan 24 21:40 .
drwxr-xr-x  1 eine None        0 Jan 24 21:40 ..
-rw-r--r--  1 eine None     7229 Apr 14  2017 InstallationLog.txt
-rw-r--r--  1 eine None       82 Jul 27  2018 autorebase.bat
-rw-r--r--  1 eine None      645 Jul 27  2018 autorebasebase1st.bat
drwxr-xr-x  1 eine None        0 May 14 23:20 bin
drwxr-xr-x  1 eine None        0 Jan 24 21:40 clang32
drwxr-xr-x  1 eine None        0 Jan 24 21:40 clang64
-rw-r--r--  1 eine None      915 Apr 14  2017 components.xml
drwxr-xr-x  1 eine None        0 Apr 14  2017 dev
-rw-r--r--  1 eine None      541 Sep 14  2017 dir
drwxr-xr-x  1 eine None        0 May 14 23:20 etc
drwxr-xr-x  1 eine None        0 May 12  2017 home
-rw-r--r--  1 eine None  2070311 Apr 14  2017 maintenancetool.dat
-rwxr-xr-x  1 eine None 27489328 Apr 14  2017 maintenancetool.exe
-rw-r--r--  1 eine None     4247 Apr 14  2017 maintenancetool.ini
drwxr-xr-x  1 eine None        0 Apr 14  2017 mingw32
-rwxr-xr-x  1 eine None    53375 Sep  7  2016 mingw32.exe
-rw-r--r--  1 eine None      154 Sep  7  2016 mingw32.ini
drwxr-xr-x  1 eine None        0 Jun 17  2017 mingw64
-rwxr-xr-x  1 eine None    53375 Sep  7  2016 mingw64.exe
-rw-r--r--  1 eine None      154 Sep  7  2016 mingw64.ini
-rw-r--r--  1 eine None     1289 Jan 18 05:15 mintty.exe.stackdump
-rwxr-xr-x  1 eine None    53375 Sep  7  2016 msys2.exe
-rw-r--r--  1 eine None    25758 Dec 15 19:46 msys2.ico
-rw-r--r--  1 eine None      151 Sep  7  2016 msys2.ini
-rw-r--r--  1 eine None     6165 Dec 15 19:46 msys2_shell.cmd
-rw-r--r--  1 eine None      362 Apr 14  2017 network.xml
drwxr-xr-x  1 eine None        0 Feb 14  2017 opt
dr-xr-xr-x 25 eine None        0 May 20 00:16 proc
-rw-r--r--  1 eine None       45 Mar 12  2018 sh.exe.stackdump
drwxr-xr-x  1 eine None        0 May 20 00:16 tmp
drwxr-xr-x  1 eine None        0 Apr 14 16:18 usr
drwxr-xr-x  1 eine None        0 Apr 14  2017 var

@mviereck
Copy link
Owner

There will be several changes for x11docker on MS Windows (#160).
I'll look at this ticket again after the changes are done.

@mviereck
Copy link
Owner

mviereck commented Jun 7, 2019

I've installed a new Windows developer VM (WinDev1905Eval) and run x11docker with runx (#165) in PowerShell:

bash /usr/bin/runx -- /usr/bin/x11docker -e xterm

It succeeds, I still cannot reproduce the issue.

As I don't intend to officially support Windows PowerShell, I'll close this ticket.

@mviereck mviereck closed this as completed Jun 7, 2019
@eine
Copy link
Contributor Author

eine commented Jun 17, 2019

PS C:\> bash
eine@DESKTOP-E1ER43H:/mnt/c$ /mnt/d/data-dev/github/runx/runx -- /mnt/d/data-dev/github/x11docker/x11docker -e xterm
runx note: MSYS2 does not provide xauth to create a cookie.
  Fallback: Enabling discouraged option --no-auth.

runx ERROR: No X server found for MSYS2.
  Please install X server VcXsrv:
      https://sourceforge.net/projects/vcxsrv

Anyway, I'll focus on #165.

@mviereck
Copy link
Owner

The issue here might be related to the failing WSL runs in #165.
WSL is somehow not detected properly.
Do you have cygcheck.exe available in WSL? That would confuse x11docker.

I've changed the order of the Cygwin/MSYS2/WSL check, maybe that fixes this issue as well as the WSL failures in #165.

Previously WSL was checked first, now at last. The new check:

  # Check for MS Windows subsystem
  command -v cygcheck.exe >/dev/null && {
    cygcheck.exe -V | rmcr | grep -q "(cygwin)"   && Winsubsystem="CYGWIN"
    cygcheck.exe -V | rmcr | grep -q "(msys)"     && Winsubsystem="MSYS2"
  }
  uname -r | grep -q "Microsoft"                  && Winsubsystem="WSL"

@eine
Copy link
Contributor Author

eine commented Jun 23, 2019

Do you have cygcheck.exe available in WSL? That would confuse x11docker.

Yes, it is available in WSL:

~$ cyg
cygcheck.exe               cygpath.exe                cygwin-console-helper.exe
~$ which cygcheck.exe
/mnt/c/msys64/usr/bin/cygcheck.exe

I've changed the order of the Cygwin/MSYS2/WSL check, maybe that fixes this issue as well as the WSL failures in #165.

It works now. Both when launching WSL or when running bash from PowerShell. Some probably fixable messages are shown:

# runx -- x11docker -e xterm
...
mkdir: cannot create directory ‘/run/user/1000’: Permission denied
chown: cannot access '/run/user/1000': No such file or directory
chmod: cannot access '/run/user/1000': No such file or directory
...

@mviereck
Copy link
Owner

It works now. Both when launching WSL or when running bash from PowerShell.

Great!

Some probably fixable messages are shown:

I'll look into this. Do you get an output in WSL or PowerShell for:

echo $XDG_RUNTIME_DIR

?

@eine
Copy link
Contributor Author

eine commented Jun 24, 2019

I'll look into this. Do you get an output in WSL or PowerShell for:

echo $XDG_RUNTIME_DIR

?

No. It's empty/unset. No matter if I check it in WSL, Cygwin or MSYS.

mviereck added a commit that referenced this issue Jun 25, 2019
@mviereck
Copy link
Owner

The mkdir ... errors are fixed. Thanks for your tests!

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

No branches or pull requests

2 participants