Search code examples
filepathscpmsys2pscp

How to prevent MSYS from converting remote file path for pscp


I'm using msys2 bash 4.3.26 (i686-pc-msys) on Windows, and recently I find that it breaks my pscp and scp (msys1):

When I run pscp req.py hostname:/home/user/xxx/yyy/:

  • msys will change the second args to hostname;D:\msys\home\user\xxx\yyy\
  • and then pscp will report: ssh_init: Host does not exist
  • my scp which is from msys-1.0 (I once used git-for-windows 1.9) reports ssh: Could not resolve hostnamehostname;d: no address associated with name

This is annoying and I have to open cmd.exe to use pscp. Is there any way to prevent MSYS 2 from convert special args?

  • I tried wrapping an arg in ' or " and failed
  • http://www.mingw.org/wiki/Posix_path_conversion is not helpful but disappointing
  • environment: Windows 10 Insider x64 and msys2 i686
  • the official scp.exe in the same package of msys2 works well

BTW, this problem only occurs on those .exe files which does not use msys2 DLLs. How this difference is being checked?


Solution

  • MSYS2 converts POSIX-style path names to Windows-style path names when it detects you are running a native Windows program like pscp. These conversions use a lot of heuristics and sometimes they get the wrong answer.

    You can inhibit conversions of certain arguments by setting the MSYS2_ARG_CONV_EXCL environment variable as you run the command. It is a list of prefixes of arguments for which MSYS2 should not attempt to convert paths. You could just set the variable to the empty string in order to turn off all conversions. However, you might need the first argument to pscp to be converted since it is a path on your local computer. So you should try running your command like this instead:

    MSYS2_ARG_CONV_EXCL=hostname pscp req.py hostname:/home/user/xxx/yyy/