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

Path conversion with and without winpty differs #411

Open
elieux opened this issue Dec 23, 2015 · 13 comments
Open

Path conversion with and without winpty differs #411

elieux opened this issue Dec 23, 2015 · 13 comments

Comments

@elieux
Copy link
Member

elieux commented Dec 23, 2015

me@pc MSYS /
$ /apps32/gnuwin32/bin/echo /w/dev //w/dev
W:/dev //w/dev

me@pc MSYS /
$ winpty /apps32/gnuwin32/bin/echo /w/dev //w/dev
W:\dev \\w\dev

Same result in MINGW64. I'm not sure why they differ, but I think it should be consistent.

Also, MSYS2_ARG_CONV_EXCL doesn't seem to affect winpty. Maybe there should also be a WINPTY_ARG_CONV=0 option as well to allow disabling of argument conversion.

@elebeaup
Copy link

I have the same issue.

$ export MSYS2_ARG_CONV_EXCL="*"
$ docker run --rm busybox /bin/echo hello world
hello world

$ winpty docker run --rm busybox /bin/echo hello world
exec: "C:\\msys64\\usr\\bin\\echo": executable file not found in $PATH
docker: Error response from daemon: Container command not found or does not exist..

@lanoxx
Copy link

lanoxx commented Dec 14, 2017

It seems that this breaks a lot of tools such as node. See: yarnpkg/yarn#2591

What help is needed to fix this?

@ErichDonGubler
Copy link
Contributor

ErichDonGubler commented Dec 14, 2017

If I recall right, a double leading forward slash (//) means something different in the context of the MSYS shell -- I know that at least one use case is to escape Windows-style options (i.e., msbuild //target:...) from being parsed as an absolute file path, which MSYS would otherwise need to convert.

Don't know if that helps, but I'm on mobile, and can't really research at the moment. :(

@niklasholm
Copy link
Contributor

Might be related rprichard/winpty#127

@rkitover
Copy link
Contributor

If you came here because your docker commands are not working, the interim solution is to use the upstream msys2 binaries for winpty and NOT the msys2 package.

Get them here: https://github.com/rprichard/winpty/releases

See related: rprichard/winpty#125

@sarangjo
Copy link

Is there any effort to update the MSYS package retrieved by pacman -S winpty to be updated to the upstream msys2 binary released at https://github.com/rprichard/winpty/releases?

@mingwandroid
Copy link
Member

mingwandroid commented Nov 17, 2018 via email

@rkitover
Copy link
Contributor

To fix the msys2 package, there are two options. Remove the path conversion patch, which may confuse some people when their paths don't work with winpty, or make a new patch with support for the MSYS2_ARG_CONV_EXCL variable.

@bruno-medeiros
Copy link

If removing the path conversion patch can be problematic (risks breaking in situations where people expect it), how about providing a version of winpty functionality without the path conversion, but under a different winpty binary, or activated with an explicit option. This way both behaviors (winpty path conversion and no winpty path conversion) would still be available and both could be used.
If you think of winpty as an API (which it is), it makes sense to provide both behaviors, and don't change the default behavior - so that nothing gets broken. And possibly deprecate the old one. Would this be a good approach?

@mikeslattery
Copy link

mikeslattery commented Oct 31, 2019

As a workaround, putting this function in .bashrc fixed the issue for me.

winpty() {
    if [[ "$1" == "docker" ]]; then
        shift
        command winpty xargs -0a <(printf "%s\0" "$@") docker
    else
        command winpty "$@"
    fi
}

@mingwandroid edited this in-case anyone misses the correction below.

@rkitover
Copy link
Contributor

rkitover commented Nov 1, 2019

@mikeslattery thank you very much for this workaround.

@djbrown
Copy link

djbrown commented Apr 28, 2020

@mikeslattery I put the function in my ~/.bashrc but I now get the following errors when loading Git-Bash:

bash: /c/Users/user/.bashrc: line 4: syntax error in conditional expression: unexpected token `;'
bash: /c/Users/user/.bashrc: line 4: syntax error near `;'
bash: /c/Users/user/.bashrc: line 4: `    if [[ "$1" == "docker"]]; then'

user@HOST MINGW64 ~
$

@rkitover
Copy link
Contributor

@djbrown there is a missing space after "docker", the line should be:

if [[ "$1" == "docker" ]]; then

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