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

Bash translates path parameter in Unix format to windows format, need a way to suppress it #577

Closed
igormukhin opened this issue Dec 19, 2015 · 8 comments
Labels

Comments

@igormukhin
Copy link

MSYSGIT version: 2.6.4

If I run the following command in git-bash terminal on my windows pc:

docker run -ti --rm -v "/c/Users/igor/Documents/Mikogo4:/app" buildpack-deps:jessie bash

bash thinks I used paths in Unix format, so it translates them to windows format which is unwanted in this case, and I get the error:

invalid value "C:\\Users\\igor\\Documents\\Mikogo4;C:\\software\\Git\\app" for flag -v

Is there is a way to suppress the automatic path translation?

@davidovich
Copy link

Add a / to suppress translation:

docker run -ti --rm -v "//c/Users/igor/Documents/Mikogo4://app

Note that you'll need to double the container path also.
On Sat, Dec 19, 2015 at 17:27 Igor Mukhin notifications@github.com wrote:

MSYSGIT version: 264

If I run the following command in git-bash terminal on my windows pc:

docker run -ti --rm -v "/c/Users/igor/Documents/Mikogo4:/app" buildpack-deps:jessie bash

bash thinks I used paths in Unix format, so it translates them to windows
format which is unwanted in this case, and I get the error:

invalid value "C:\Users\igor\Documents\Mikogo4;C:\software\Git\app" for flag -v

Is there is a way to suppress the automatic path translation?


Reply to this email directly or view it on GitHub
#577.

@dscho
Copy link
Member

dscho commented Dec 20, 2015

MSYSGIT

Nope. MSYSGIT is almost certainly not what you think it is. What you refer to is Git for Windows.

docker run -ti --rm -v "/c/Users/igor/Documents/Mikogo4:/app" buildpack-deps:jessie bash

bash thinks I used paths in Unix format

From the release notes' known issues:

  • If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe". When that is not desired -- e.g. "--upload-pack=/opt/git/bin/git-upload-pack" or "-L/regex/" -- you need to set the environment variable MSYS_NO_PATHCONV temporarily, like so:

MSYS_NO_PATHCONV=1 git blame -L/pathconv/ msys2_path_conv.cc

Alternatively, you can double the first slash to avoid POSIX-to-Windows path conversion.

@chefren
Copy link

chefren commented Jun 11, 2020

If you require the argument to have a starting "/" then the workaround fails, MSYS2 has an option for this, but it's another tool :(

@s100
Copy link

s100 commented Mar 2, 2021

@dsco Apologies for dredging up such an ancient issue but this isn't working for me. I have just installed the latest Git for Windows from https://git-scm.com/download/win, I open a fresh window,

$ node -e "console.log(process.argv)" -- /a/b/c
[ 'C:\\Program Files\\nodejs\\node.exe', 'A:/b/c' ]

$ MSYS_NO_PATHCONV=1 node -e 'console.log(process.argv)' -- /a/b/c
[ 'C:\\Program Files\\nodejs\\node.exe', 'A:/b/c' ]

What am I missing? I can't put a leading slash on the front, and this is not a path. I need to pass the six-character string "/a/b/c" as an argument to my script, unaltered. I saw elsewhere to try MSYS2_ARG_CONV_EXCL="*" but that had no effect either:

$ set -f MSYS2_ARG_CONV_EXC="*"

$ echo $MSYS2_ARG_CONV_EXC
*

$ node -e "console.log(process.argv)" -- /a/b/c
[ 'C:\\Program Files\\nodejs\\node.exe', 'A:/b/c' ]

@dscho
Copy link
Member

dscho commented Mar 4, 2021

@dsco

Almost, but not quite.

$ MSYS_NO_PATHCONV=1 node -e 'console.log(process.argv)' -- /a/b/c

It seems that node being a Bash alias makes this method fail (or maybe it is the winpty.exe program that ignores MSYS_NO_PATHCONV). Try with node.exe instead of node.

@dscho
Copy link
Member

dscho commented Mar 4, 2021

$ set -f MSYS2_ARG_CONV_EXC="*"

You don't set environment variables that way in Bash, skip the set -f. Also, note that MSYS2_ARG_CONV_EXCL is spelled with a trailing L: https://github.com/git-for-windows/msys2-runtime/blob/87cc056b5c531ba998a83bccdacc8dee2bac15ef/winsup/cygwin/spawn.cc#L290

@s100
Copy link

s100 commented Mar 4, 2021

It seems that node being a Bash alias makes this method fail (or maybe it is the winpty.exe program that ignores MSYS_NO_PATHCONV). Try with node.exe instead of node.

$ alias
alias ll='ls -l'
alias ls='ls -F --color=auto --show-control-chars'
alias node='winpty node.exe'

$ winpty -- echo /a/b/c
A:/b/c

$ MSYS_NO_PATHCONV=1 node.exe -e "console.log(process.argv)" -- /a/b/c
[ 'C:\\Program Files\\nodejs\\node.exe', '/a/b/c' ]

Astounding. It was the alias I was missing. Thank you.

@ehillis
Copy link

ehillis commented Jun 9, 2023

Try
export MSYS_NO_PATHCONV=1
in a separate command then run your other commands, and / should not be converted

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

No branches or pull requests

6 participants