From 9f2a28c2f5856532dada7d9930e324e3426a3037 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 14 Feb 2026 00:35:23 +0000 Subject: [PATCH 1/3] Configure Git Bash shell profiles during Windows install Git Bash (MSYS2/MinGW) prepends /mingw64/bin to PATH during shell initialization, which shadows the git-ai shim even when the Windows PATH has been correctly configured. Fix this by detecting Git for Windows installations and writing an export PATH line to ~/.bashrc or ~/.bash_profile, mirroring what install.sh already does for Unix shells. Closes #517 Co-Authored-By: Sasha Varlamov --- install.ps1 | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/install.ps1 b/install.ps1 index cbfc1cb19..a445b421d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -434,6 +434,72 @@ if ($pathUpdate.MachineStatus -eq 'Updated') { Write-Success "Successfully installed git-ai into $installDir" Write-Success "You can now run 'git-ai' from your terminal" +# Configure Git Bash shell profiles so git-ai takes precedence over /mingw64/bin/git +# Git Bash (MSYS2/MinGW) prepends its own directories to PATH, which shadows +# the Windows PATH entry we set above. Writing to ~/.bashrc ensures git-ai's +# bin directory is prepended after Git Bash's own PATH setup. +$gitBashConfigured = $false +$gitBashAlreadyConfigured = $false +try { + $bashrcPath = Join-Path $HOME '.bashrc' + $bashProfilePath = Join-Path $HOME '.bash_profile' + $pathCmd = 'export PATH="$HOME/.git-ai/bin:$PATH"' + $markerString = '.git-ai/bin' + + # Detect if Git Bash is installed + $gitBashInstalled = $false + $gitForWindowsPaths = @( + (Join-Path $env:ProgramFiles 'Git\bin\bash.exe'), + (Join-Path ${env:ProgramFiles(x86)} 'Git\bin\bash.exe'), + (Join-Path $env:LOCALAPPDATA 'Programs\Git\bin\bash.exe') + ) + foreach ($p in $gitForWindowsPaths) { + if ($p -and (Test-Path -LiteralPath $p)) { + $gitBashInstalled = $true + break + } + } + + if ($gitBashInstalled) { + # Determine which config file to update (prefer .bashrc, fall back to .bash_profile) + $targetBashConfig = $null + if (Test-Path -LiteralPath $bashrcPath) { + $targetBashConfig = $bashrcPath + } elseif (Test-Path -LiteralPath $bashProfilePath) { + $targetBashConfig = $bashProfilePath + } else { + # No existing config; create .bashrc + $targetBashConfig = $bashrcPath + } + + # Check if already configured + $alreadyPresent = $false + if (Test-Path -LiteralPath $targetBashConfig) { + $content = Get-Content -LiteralPath $targetBashConfig -Raw -ErrorAction SilentlyContinue + if ($content -and $content.Contains($markerString)) { + $alreadyPresent = $true + } + } + + if ($alreadyPresent) { + $gitBashAlreadyConfigured = $true + } else { + $timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' + $appendContent = "`n# Added by git-ai installer on $timestamp`n$pathCmd`n" + Add-Content -LiteralPath $targetBashConfig -Value $appendContent -Encoding UTF8 + $gitBashConfigured = $true + } + } +} catch { + Write-Host "Warning: Failed to configure Git Bash: $($_.Exception.Message)" -ForegroundColor Yellow +} + +if ($gitBashConfigured) { + Write-Success "Successfully configured Git Bash ($targetBashConfig)" +} elseif ($gitBashAlreadyConfigured) { + Write-Success "Git Bash already configured ($targetBashConfig)" +} + # Write JSON config at %USERPROFILE%\.git-ai\config.json (only if it doesn't exist) try { $configDir = Join-Path $HOME '.git-ai' From 967e04391ec8b3bf4b04e69a438784a19e66e174 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 15 Feb 2026 20:09:53 +0000 Subject: [PATCH 2/3] Use BOM-less UTF-8 encoding for .bashrc writes PowerShell 5.1's Add-Content -Encoding UTF8 writes a UTF-8 BOM that causes 'command not found' errors in bash. Use .NET's UTF8Encoding(false) + AppendAllText instead to avoid the BOM. Co-Authored-By: Sasha Varlamov --- install.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index a445b421d..961b5c648 100644 --- a/install.ps1 +++ b/install.ps1 @@ -486,7 +486,8 @@ try { } else { $timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss' $appendContent = "`n# Added by git-ai installer on $timestamp`n$pathCmd`n" - Add-Content -LiteralPath $targetBashConfig -Value $appendContent -Encoding UTF8 + $utf8NoBom = New-Object System.Text.UTF8Encoding($false) + [System.IO.File]::AppendAllText($targetBashConfig, $appendContent, $utf8NoBom) $gitBashConfigured = $true } } From cc05130cfe82ba95d7ef1221cac369b775b7dadb Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 04:04:29 +0000 Subject: [PATCH 3/3] Guard Join-Path calls against null env vars On 32-bit Windows, env vars like ProgramFiles(x86) may be null, causing Join-Path to throw under StrictMode before the null-guard in the loop could run. Build the array conditionally instead. Co-Authored-By: Sasha Varlamov --- install.ps1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index 961b5c648..5c587317a 100644 --- a/install.ps1 +++ b/install.ps1 @@ -448,11 +448,10 @@ try { # Detect if Git Bash is installed $gitBashInstalled = $false - $gitForWindowsPaths = @( - (Join-Path $env:ProgramFiles 'Git\bin\bash.exe'), - (Join-Path ${env:ProgramFiles(x86)} 'Git\bin\bash.exe'), - (Join-Path $env:LOCALAPPDATA 'Programs\Git\bin\bash.exe') - ) + $gitForWindowsPaths = @() + if ($env:ProgramFiles) { $gitForWindowsPaths += Join-Path $env:ProgramFiles 'Git\bin\bash.exe' } + if (${env:ProgramFiles(x86)}) { $gitForWindowsPaths += Join-Path ${env:ProgramFiles(x86)} 'Git\bin\bash.exe' } + if ($env:LOCALAPPDATA) { $gitForWindowsPaths += Join-Path $env:LOCALAPPDATA 'Programs\Git\bin\bash.exe' } foreach ($p in $gitForWindowsPaths) { if ($p -and (Test-Path -LiteralPath $p)) { $gitBashInstalled = $true