Skip to content

fix(components/gga): gga.ps1 shim picks wrong bash.exe path when git is in mingw64\bin (Windows) #932

Description

@diegnghtmr

Pre-flight Checklist

  • I have searched existing issues and this is not a duplicate
  • I understand that PRs will be rejected if the linked issue does not have status:approved

Related but distinct from #924 (that issue is about doctor PATHEXT detection + a false "3 copies" warning, and explicitly assumes gga.ps1 works). This report is about the gga.ps1 shim itself failing to locate bash.exe. Shim was introduced in #101.

📝 Bug Description

The generated gga.ps1 PowerShell shim (asset internal/assets/gga/gga.ps1) derives Git Bash from git's location with a single, fragile assumption:

$bash = Join-Path (Split-Path (Split-Path $gitCmd.Source)) "bin\bash.exe"

This only holds when git resolves from <GitRoot>\cmd\git.exe (two Split-Path ups → <GitRoot>, then bin\bash.exe is valid).

When git resolves from <GitRoot>\mingw64\bin\git.exe — common when mingw64\bin precedes cmd on PATH, or with certain Git installs — the shim computes <GitRoot>\mingw64\bin\bash.exe, which does not exist. The real bash.exe lives at <GitRoot>\bin\bash.exe and <GitRoot>\usr\bin\bash.exe.

Net effect: gga is completely unusable from PowerShell for affected users (the shim exits before ever reaching the bash script).

Note: the robust resolver already exists in Go at internal/installcmd/resolver.go (it tries multiple candidates + known locations), but the runtime PowerShell shim does not mirror that logic.

🔄 Steps to Reproduce

  1. Windows machine where git resolves to the mingw64 copy. Verify with:
    (Get-Command git).Source
    # -> C:\Program Files\Git\mingw64\bin\git.exe
  2. Have gga installed via the ecosystem (gga.ps1 shim present in a PATH dir, e.g. C:\Users\<user>\bin\gga.ps1).
  3. From PowerShell, run:
    gga --version

✅ Expected Behavior

The shim locates Git Bash regardless of whether git resolves from cmd\, bin\, or mingw64\bin\, then runs gga (e.g. prints gga v2.8.1).

❌ Actual Behavior

gga.ps1: Git Bash not found at 'C:\Program Files\Git\mingw64\bin\bash.exe'. Reinstall Git for Windows.

Exit code 1. bash.exe actually exists at C:\Program Files\Git\bin\bash.exe and C:\Program Files\Git\usr\bin\bash.exe.

Gentle AI Version

1.40.2

Operating System

Windows

AI Agent / Client

Claude Code

📋 Affected Area

Installation Pipeline

💡 Logs / Error Output

PS> (Get-Command git).Source
C:\Program Files\Git\mingw64\bin\git.exe

PS> gga --version
gga.ps1: Git Bash not found at 'C:\Program Files\Git\mingw64\bin\bash.exe'. Reinstall Git for Windows.

PS> Test-Path 'C:\Program Files\Git\bin\bash.exe'
True
PS> Test-Path 'C:\Program Files\Git\mingw64\bin\bash.exe'
False

Additional Context

Suggested fix — mirror the Go resolver inside the shim: try bash.exe on PATH (excluding the WSL launcher in System32), then walk up from git's directory trying both bin\bash.exe and usr\bin\bash.exe at each level, then fall back to known install locations:

$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if (-not $gitCmd) {
    Write-Error "Git not found on PATH. Install Git for Windows to use gga from PowerShell."
    exit 1
}

$bash = $null
$bashCmd = Get-Command bash.exe -ErrorAction SilentlyContinue |
    Where-Object { $_.Source -notlike "$env:WINDIR\System32\*" } |
    Select-Object -First 1
if ($bashCmd) { $bash = $bashCmd.Source }

if (-not $bash) {
    $candidates = @()
    $dir = Split-Path $gitCmd.Source
    for ($i = 0; $i -lt 4 -and $dir; $i++) {
        $candidates += (Join-Path $dir 'bin\bash.exe')
        $candidates += (Join-Path $dir 'usr\bin\bash.exe')
        $dir = Split-Path $dir
    }
    $candidates += 'C:\Program Files\Git\bin\bash.exe'
    $candidates += 'C:\Program Files\Git\usr\bin\bash.exe'
    $bash = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
}

if (-not $bash) {
    Write-Error "Git Bash (bash.exe) not found. Reinstall Git for Windows or add its bin directory to PATH."
    exit 1
}

& $bash -c "gga $args"
exit $LASTEXITCODE

Verified locally: applying the above makes gga --version return gga v2.8.1 (exit 0) and gga --help work from PowerShell on a machine where git is in mingw64\bin.

Environment

  • OS: Windows 11
  • gentle-ai: 1.40.2 (installed via Scoop)
  • gga: v2.8.1
  • git: C:\Program Files\Git\mingw64\bin\git.exe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions