gitautohotkeygit-guicygpath

cygpath not found in PATH launching Git GUI from Windows run dialog


I use Autohotkey to launch Git Gui and gitk and tile them side by side:

:*:gth::
{
    GitToolsHere(A_Clipboard)
}

GitToolsHere(path)
{
    GitGuiHere(path)
    GitkHere(path)
}

; Open GitGUI at path
GitGuiHere(path)
{
    arr := strsplit(path,"\")
    folder := arr[arr.length]
    pathAsUnix := StrReplace(path, "\", "/")
    ; 3: A window's title must exactly match WinTitle to be a match.
    SetTitleMatchMode 3
    Run '"C:\Program Files\Git\mingw64\bin\wish.exe" "C:\Program Files\Git\mingw64\libexec\git-core"\git-gui -- "--working-dir" "' . path . '"'
    WinWait 'Git Gui (' . folder . ') ' . pathAsUnix,,5
    WinMove -7, 0, 974, 1167
    ; 2: Default behavior. A window's title can contain WinTitle anywhere inside it to be a match.
    SetTitleMatchMode 2
}

; Open GitK at path
GitkHere(path)
{
    arr := strsplit(path,"\")
    folder := arr[arr.length]

    ; 3: A window's title must exactly match WinTitle to be a match.
    SetTitleMatchMode 3
    SetWorkingDir path
    gitkCmd := Quote("C:\Program Files\Git\mingw64\bin\wish.exe") " " Quote("C:/Program Files/Git/mingw64/bin/gitk") " --all -- --"
    Run gitkCmd
    WinWait folder . ': --all - gitk',,5
    WinMove 953, 0, 974, 1167
    ; 2: Default behavior. A window's title can contain WinTitle anywhere inside it to be a match.
    SetTitleMatchMode 2
    SetWorkingDir A_InitialWorkingDir
}

; Wrap string in quotes
Quote(text)
{
    return chr(34) . text . chr(34)
}

In Git GUI version:

git-gui version 0.21.GITGUI git version 2.49.0.windows.1 Tcl/Tk version 8.6.13

Everything worked fine. I am now running:

git-gui version 0.21.GITGUI git version 2.51.2.windows.1 Tcl/Tk version 8.6.16

Now when my command runs I get this error:

---------------------------
Error in startup script
---------------------------
cygpath not found in PATH
    while executing
"throw {NOT-FOUND} "$cmd not found in PATH""
    (procedure "sanitize_command_line" line 8)
    invoked from within
"sanitize_command_line $args $i"
    (procedure "exec" line 13)
    invoked from within
"exec cygpath -m /bin/sh"
    ("eval" body line 1)
    invoked from within
"eval exec [make_arglist_safe $cmd]"
    (procedure "safe_exec" line 2)
    invoked from within
"safe_exec [list cygpath -m $_shellpath]"
    (file "C:/Program Files/Git/mingw64/libexec/git-core/git-gui.tcl" line 407)
    invoked from within
"source [file join $thisdir git-gui.tcl]"
    (file "C:\Program Files\Git\mingw64\libexec\git-core\git-gui" line 17)
---------------------------
OK   
---------------------------

The command line that I build in AutoHotKey was obtained using Windows Sysinternals Process Explorer. I used that tool to inspect the command line used when the Git GUI is launched from the folder context menu. I have checked this again with the updated version of Git and cannot see any differences. Also if I copy the same command line and try to run it using the Windows run dialog I get the same issue.

I don't understand why it is not working, can anyone help?


Solution

  • Versions of Git GUI included in Git before version 2.51.0 did not require cygpath, but now do require it. It is necessary that the directory containing the MSYS binaries is in PATH.

    If you haven't requested during installation of Git for Windows that PATH is changed, then you must set PATH in your script to include C:\Program Files\Git\usr\bin before wish.exe is run.