fix(install): don't abort install.ps1 when git writes to stderr (#80834)

PowerShell 7+ honors $ErrorActionPreference=Stop for native commands,
so git's normal progress line ("From https://...") on stderr during
`git pull --rebase` would turn into a terminating error and abort the
installer immediately after a fresh clone — before pnpm install/build
ever runs. The existing `2>$null` redirects the display but the error
record is still generated.

Wrap the git status / pull calls in try/catch so the pull stays
best-effort and the rest of the installer can proceed. Reproduced on
Windows 11 ARM under PowerShell 7.x with -InstallMethod git.
This commit is contained in:
Sarah Fortune
2026-05-12 17:26:30 -07:00
committed by GitHub
parent 31ea86bf7d
commit d06f0a0ee7

View File

@@ -568,8 +568,13 @@ function Install-OpenClawFromGit {
}
if (-not $SkipUpdate) {
if (-not (git -C $RepoDir status --porcelain 2>$null)) {
git -C $RepoDir pull --rebase 2>$null
# PowerShell 7+ surfaces native-command stderr as terminating errors when
# $ErrorActionPreference=Stop, so git's normal "From <url>" progress line
# would abort the script. Swallow failures here — pull is best-effort.
$dirty = $null
try { $dirty = git -C $RepoDir status --porcelain 2>$null } catch {}
if (-not $dirty) {
try { git -C $RepoDir pull --rebase 2>$null } catch {}
} else {
Write-Host "[!] Repo is dirty; skipping git pull" -ForegroundColor Yellow
}