From d1c493f031770bab9c81496f2222f825c42beb3f Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 9 Jun 2026 13:10:20 +0800 Subject: [PATCH] fix(install): check LASTEXITCODE after git commands in install.ps1 PowerShell's $ErrorActionPreference = 'Stop' only applies to cmdlets, not external commands like git. When git clone or git pull fails (e.g. network timeout), the script continued executing and crashed at Get-SkillNames because the repo directory didn't exist. Add explicit $LASTEXITCODE checks after all git invocations (Clone-Or-Update and Cmd-Update) to halt immediately on failure. --- install.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/install.ps1 b/install.ps1 index 1a4b4df3..a2bfffe6 100644 --- a/install.ps1 +++ b/install.ps1 @@ -87,11 +87,17 @@ function Clone-Or-Update { if (Test-Path (Join-Path $RepoDir '.git')) { Write-Host "→ Updating existing checkout at $RepoDir" git -C $RepoDir pull --ff-only + if ($LASTEXITCODE -ne 0) { + Write-Error "git pull failed (exit code $LASTEXITCODE). Check your network and try again." + } } else { Write-Host "→ Cloning $RepoUrl → $RepoDir" $parent = Split-Path -Parent $RepoDir if (-not (Test-Path $parent)) { New-Item -ItemType Directory -Path $parent | Out-Null } git clone $RepoUrl $RepoDir + if ($LASTEXITCODE -ne 0) { + Write-Error "git clone failed (exit code $LASTEXITCODE). Check your network and try again." + } } } @@ -225,6 +231,9 @@ function Cmd-Update { Write-Error "No installation found at $RepoDir. Run install first." } git -C $RepoDir pull --ff-only + if ($LASTEXITCODE -ne 0) { + Write-Error "git pull failed (exit code $LASTEXITCODE). Check your network and try again." + } Write-Host '✓ Updated.' }