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

Version 0.4.3 that comes with git bash 2.14.1 cannot execute cmd.exe #127

Open
tarruda opened this issue Aug 11, 2017 · 6 comments
Open

Comments

@tarruda
Copy link

tarruda commented Aug 11, 2017

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.

@rprichard
Copy link
Owner

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 #81 / #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.

@rprichard
Copy link
Owner

Related to #88.

@lanoxx
Copy link

lanoxx commented Dec 14, 2017

Hello Richard,

what needs to be done to fix this? Do you need some help with this?

@noxware
Copy link

noxware commented Dec 3, 2019

Any progress?

@vipzen
Copy link

vipzen commented Feb 13, 2020

+1

@evandrocoan
Copy link

As pointed by msys2/MSYS2-packages#411 (comment) , 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
image

  1. pacman -R winpty
  2. wget https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msys2-2.7.0-x64.tar.gz
  3. tar -xvf winpty-0.4.3-msys2-2.7.0-x64.tar.gz
  4. cd winpty-0.4.3-msys2-2.7.0-x64/bin
  5. cp * /usr/bin

Now it correctly opens cmd.exe from bash with $ winpty cmd.exe.

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

No branches or pull requests

6 participants