fix: PowerShell NativeCommandError on git stderr output

PowerShell with $ErrorActionPreference = 'Stop' treats ANY stderr
output from native commands as a terminating NativeCommandError —
even successful git operations that write progress to stderr
(e.g. 'Cloning into ...').

Fix: temporarily set $ErrorActionPreference = 'Continue' around all
git commands (clone, fetch, checkout, pull, submodule update). This
lets git run normally while preserving strict error handling for
the rest of the installer.
This commit is contained in:
teknium1 2026-03-02 22:10:31 -08:00
parent bdf4758510
commit cdf5375b9a

View file

@ -416,9 +416,12 @@ function Install-Repository {
if (Test-Path "$InstallDir\.git") { if (Test-Path "$InstallDir\.git") {
Write-Info "Existing installation found, updating..." Write-Info "Existing installation found, updating..."
Push-Location $InstallDir Push-Location $InstallDir
git fetch origin $savedEAP = $ErrorActionPreference
git checkout $Branch $ErrorActionPreference = "Continue"
git pull origin $Branch git fetch origin 2>&1 | Out-Null
git checkout $Branch 2>&1 | Out-Null
git pull origin $Branch 2>&1 | Out-Null
$ErrorActionPreference = $savedEAP
Pop-Location Pop-Location
} else { } else {
Write-Err "Directory exists but is not a git repository: $InstallDir" Write-Err "Directory exists but is not a git repository: $InstallDir"
@ -426,6 +429,13 @@ function Install-Repository {
exit 1 exit 1
} }
} else { } else {
# Git writes progress to stderr. With $ErrorActionPreference = "Stop",
# PowerShell treats ANY stderr output from native commands as a
# terminating NativeCommandError — even successful git clones.
# Temporarily relax this so git can run normally.
$savedEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
# Try SSH first (for private repo access), fall back to HTTPS. # Try SSH first (for private repo access), fall back to HTTPS.
# GIT_SSH_COMMAND with BatchMode=yes prevents SSH from hanging # GIT_SSH_COMMAND with BatchMode=yes prevents SSH from hanging
# when no key is configured (fails immediately instead of prompting). # when no key is configured (fails immediately instead of prompting).
@ -446,16 +456,25 @@ function Install-Repository {
if ($LASTEXITCODE -eq 0) { if ($LASTEXITCODE -eq 0) {
Write-Success "Cloned via HTTPS" Write-Success "Cloned via HTTPS"
} else { } else {
$ErrorActionPreference = $savedEAP
Write-Err "Failed to clone repository" Write-Err "Failed to clone repository"
exit 1 exit 1
} }
} }
$ErrorActionPreference = $savedEAP
} }
# Ensure submodules are initialized and updated # Ensure submodules are initialized and updated
Write-Info "Initializing submodules (mini-swe-agent, tinker-atropos)..." Write-Info "Initializing submodules (mini-swe-agent, tinker-atropos)..."
Push-Location $InstallDir Push-Location $InstallDir
git submodule update --init --recursive
# Same stderr issue applies to git submodule commands
$savedEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
git submodule update --init --recursive 2>&1 | Out-Null
$ErrorActionPreference = $savedEAP
Pop-Location Pop-Location
Write-Success "Submodules ready" Write-Success "Submodules ready"