#25 Path control


I'm really enjoying this new setup with msys2. One problem I ran into today though was with paths. I've noticed that paths are usually printed "/c/Users/example/path". Is there a reason to not just use standard windows path formatting? i.e. "C:\Users\example\path"?
My use case today was running some git scripts. Usually I pass a windows path to git, but with this setup, I'm not getting errors like "/c/Users/karbarcca/C:\Users\karbarcca\test\repo.git does not exist", because git isn't recognizing my windows path as an actual path. Not sure if this is specific to git, but I'd appreciate any insight on ways to work around or what to do to make this work.


  • Ray Donnelly

    Ray Donnelly - 2014-02-25

    Glad you are enjoying it so far.

    MSYS2 is a Posix/Unix/Linux-y environment heavily based on Cygwin. MSYS was historically defined as the minimal system needed to allow using Unix build tools to build native (i.e. non-MSYS2) Windows programs.

    These build systems (usually implemented in Autotools, shell script and GNU make or sometimes Perl/Python) expect (i.e. require) a much more simple and sane file hierarchy system where there is a single root directory, as opposed to Windows which has a horrible system of drive letters where there's up to 26 separate hierarchies and no way to express a relative path between two paths on different drives.

    The other bad thing with the Windows way of specifying paths is that the backslash it uses as a directory separator is commonly used as an escape character (in both C and shell code), so you often have to double up backslashes to work around this. I would recommend that even if you are using Windows paths, to avoid using backslashes. Windows is quite happy to work forward slashes in nearly all situations.

    The decision about which programs should be MSYS2 and which should be native isn't clear-cut. You mention Git. Ironically, despite its development project name (msysGit), the official Git for Windows is a native Windows program (it just comes bundled with a very old version of MSYS), whereas the Git we supply is an MSYS2 program.

    Sometimes we provide both MSYS2 and native versions where it makes pragmatic sense to (for example Python 2/3), but for our Git you'll have to make your scripts handle the MSYS2 conventions.

    To convert between Windows and Unix paths you can use:

    Windows -> MSYS2
    cygpath -u C:\msys64

    MSYS2 -> Windows (with less good backslashes)
    cygpath -w /usr

    MSYS2 -> Windows (with more good forward slashes)
    cygpath -m /usr
    (for the current directory, 'pwd -W' output it in this form).

    I'd recommend that you use bash script when scripting in MSYS2. There are various pragmatic features (hacks some would say) where paths and environment variables are converted at the interface between MSYS2 and native Windows programs.

  • Alexx83

    Alexx83 - 2014-06-12
    • status: open --> closed
    • assigned_to: Ray Donnelly

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks