winpty
winpty copied to clipboard
Version 0.4.3 that comes with git bash 2.14.1 cannot execute cmd.exe
This was tested on windows 7 pro with latest updates.
Every time I type winpty cmd.exe
in git bash prompt, it will exit immediately with no error message. I also notice that it creates an .exe
subdirectory in the current directory, because after the second winpty cmd.exe
it reports an error: "A subdirectory or file .exe already exists"
Other commands such as python.exe/node.exe/powershell.exe seem to work fine.
The problem reproduces in MSYS2 without the Git-for-Windows packaging. The root cause is this MSYS2 patch which uses backslashes instead of forward slashes.
https://github.com/Alexpux/MSYS2-packages/blob/ec549593cd9874c801b3a95106d032d23b3ac0b8/winpty/0002-fix-path-conversion.patch#L38
Maybe the fix for https://github.com/rprichard/winpty/issues/81 / https://github.com/rprichard/winpty/issues/98 probably contributes to the issue by making winpty use absolute paths more often.
With the MSYS2 patch, winpty-agent.exe runs C:/Windows/System32/cmd.exe
. With upstream winpty, it would instead run C:\Windows\System32\cmd.exe
. cmd.exe
does not like being started with forward slashes. It seems to interpret the absolute path as the command /c md .exe
. e.g.:
C:\Users\rprichard>C:/Windows/System32/cmd.exe
A subdirectory or file .exe already exists.
C:\Users\rprichard>cmd /cmd.exe
A subdirectory or file .exe already exists.
C:\Users\rprichard>cmd /c md .exe
A subdirectory or file .exe already exists.
Upstream winpty should use MSYS2's special path conversion somehow, but AFAIK, there's no public API for it exposed from MSYS-2.0.dll
. I suppose I should just copy what MSYS2-packages does and import the CC0-marked path_conv.cpp
files.
Related to https://github.com/rprichard/winpty/issues/88.
Hello Richard,
what needs to be done to fix this? Do you need some help with this?
Any progress?
+1
As pointed by https://github.com/msys2/MSYS2-packages/issues/411#issuecomment-372585320 , I managed to fix this issue by not installing the package from the msys2 repository (i.e., pacman -S winpty
), but downloading directly the binary from the winpty release page: https://github.com/rprichard/winpty/releases
-
pacman -R winpty
-
wget https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msys2-2.7.0-x64.tar.gz
-
tar -xvf winpty-0.4.3-msys2-2.7.0-x64.tar.gz
-
cd winpty-0.4.3-msys2-2.7.0-x64/bin
-
cp * /usr/bin
Now it correctly opens cmd.exe
from bash
with $ winpty cmd.exe
.