msys2 / msys2-runtime

Our friendly fork of Cygwin 💖 https://cygwin.org 💖 see the wiki for details

Home Page:https://github.com/msys2/msys2-runtime/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error when caling msys2_shell.cmd from WSL

alanlivio opened this issue · comments

I received the following error when calling msys2_shell.cmd from WSL

alan@elendil:~$ cmd.exe /mnt/c/msys64/msys2_shell.cmd -defterm -mingw64 -no-start -use-full-path -here
'\\wsl.localhost\Ubuntu\home\alan'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.

Try this instead

 cmd.exe /c "C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -use-full-path -here"

many thanks @Biswa96 but same behavior.

alan@elendil:~
$  cmd.exe /c "C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -use-full-path -here"
'\\wsl.localhost\Ubuntu\home\alan'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.

I am not sure why it is not working. But it's working in my system.

image

I am not sure why it is not working. But it's working in my system.

@Biswa96, are you sure you shared the right screenshot?
The error looks the same as in @alanlivio's comment.

The message in screenshot is not an error. It is expected behaviour for Command Prompt.

Thanks again. Yes. I was referring to the message "CMD.EXE started...".
At least, is there a way to say which directory msys2 should open (instead of /c/Windows)?

At least, is there a way to say which directory msys2 should open (instead of /c/Windows)?

Use -where option with that command. For example,

 cmd.exe /c "C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -use-full-path -where C:\Windows\SystemResources\ShellComponents\pris"

msys64\msys2_shell.cmd /? command shows various options and their uses.

Many thanks. I will close the issue.

@alanlivio, you can also use UNC path for -where I guess.

I tried them in pure MSYS2 environment, and they work:
image

Via: https://stackoverflow.com/questions/10233330/cygwin-file-copy-to-unc-share/10235880#10235880

The "UNC paths are not supported" warning is coming from WSL and Windows path conversion. cygwin or msys2 is not related to that. The current directory in WSL is ~ i.e. home directory. It translates to \\wsl.localhost\Ubuntu\home\alan in OP's case.

The above warning can be resolved when the current working directory is a Windows directory. For example, in this screenshot, I invoked the msys2_shell.cmd script in C:\ directory i.e. /mnt/c/ in WSL by-default. And it does not show the warning message.

image

many thanks @sskras.

It worked in a pure msys2 environment and in a msys2 created from WSL.

image

image

@alanlivio, not at all. The command still doesn't get you to you WSL home-dir anyway (IOW you still need to run two commands).

I wonder if anything changes if you swap the last two commands:

$ cd '\\wsl.localhost\Ubuntu\home\alan'
$ cmd.exe /c "C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -use-full-path -here"

EDIT: Nevermind, accessing UNC paths / Windows shares requires to mount them in WSL:
https://askubuntu.com/questions/1397506/access-windows-network-shares-from-ubuntu-shell-in-wsl/1397507#1397507
... so that won't work. Sorry for the noise.

@Biswa96:

The "UNC paths are not supported" warning is coming from WSL and Windows path conversion.

Yes, you already wrote that in a comment above.

cygwin or msys2 is not related to that. The current directory in WSL is ~ i.e. home directory. It translates to \\wsl.localhost\Ubuntu\home\alan in OP's case.

I disagree. MSYS2 relation is following – it implemented msys2_shell.cmd as a way to bootstrap the environment. The latter is based on CMD and involves the UNC limitation you mentioned already.

So it's the MSYS2 decision to use the limiting technology (instead of using eg. WSH technology).
It leads to the 2nd argument being not passed-through to the final environment (MINGW64).

That's the issue.

The above warning can be resolved when the current working directory is a Windows directory. For example, in this screenshot, I invoked the msys2_shell.cmd script in C:\ directory i.e. /mnt/c/ in WSL by-default. And it does not show the warning message.

Yes but IMO the aim is not to avoid the warning.
The aim is to get into UNC dir like \\wsl.localhost\Ubuntu\home\alan automatically, in a scripted way.

Hence the bugreport. I hope @alanlivio will correct me if I got this wrong.