mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(install.ps1): handle uv stderr output with ErrorActionPreference=Stop
On fresh Windows installs, `uv python install` writes download progress to stderr. With $ErrorActionPreference = 'Stop' (set globally in the script), PowerShell wraps those stderr lines as ErrorRecord objects when captured via 2>&1, then throws a terminating exception — landing in the catch block even though uv exits 0 and Python was installed successfully. Fix: temporarily set ErrorActionPreference to 'Continue' around the native uv call, then verify success with `uv python find` which is the reliable signal regardless of exit code / stderr noise. Tested on Windows 11 (build 26200) with ExecutionPolicy=Restricted, uv 0.11.11, fresh machine with no prior Python install.
This commit is contained in:
parent
e0c03defd5
commit
ec1714e71f
1 changed files with 23 additions and 8 deletions
|
|
@ -145,15 +145,30 @@ function Test-Python {
|
||||||
# Python not found — use uv to install it (no admin needed!)
|
# Python not found — use uv to install it (no admin needed!)
|
||||||
Write-Info "Python $PythonVersion not found, installing via uv..."
|
Write-Info "Python $PythonVersion not found, installing via uv..."
|
||||||
try {
|
try {
|
||||||
|
# Temporarily relax ErrorActionPreference: uv writes download progress
|
||||||
|
# to stderr, and with $ErrorActionPreference = "Stop" PowerShell wraps
|
||||||
|
# those stderr lines as ErrorRecord objects via 2>&1, then throws a
|
||||||
|
# terminating exception — even when uv exits 0. This caused fresh
|
||||||
|
# installs to fail on the first run despite Python being installed
|
||||||
|
# successfully. We verify success with `uv python find` afterwards
|
||||||
|
# which is the reliable signal regardless of exit code semantics.
|
||||||
|
$prevEAP = $ErrorActionPreference
|
||||||
|
$ErrorActionPreference = "Continue"
|
||||||
$uvOutput = & $UvCmd python install $PythonVersion 2>&1
|
$uvOutput = & $UvCmd python install $PythonVersion 2>&1
|
||||||
if ($LASTEXITCODE -eq 0) {
|
$uvExitCode = $LASTEXITCODE
|
||||||
$pythonPath = & $UvCmd python find $PythonVersion 2>$null
|
$ErrorActionPreference = $prevEAP
|
||||||
if ($pythonPath) {
|
|
||||||
$ver = & $pythonPath --version 2>$null
|
# Check if Python is now available (more reliable than exit code
|
||||||
Write-Success "Python installed: $ver"
|
# since uv may return non-zero due to "already installed" etc.)
|
||||||
return $true
|
$pythonPath = & $UvCmd python find $PythonVersion 2>$null
|
||||||
}
|
if ($pythonPath) {
|
||||||
} else {
|
$ver = & $pythonPath --version 2>$null
|
||||||
|
Write-Success "Python installed: $ver"
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
# uv ran but Python still not findable — show what happened
|
||||||
|
if ($uvExitCode -ne 0) {
|
||||||
Write-Warn "uv python install output:"
|
Write-Warn "uv python install output:"
|
||||||
Write-Host $uvOutput -ForegroundColor DarkGray
|
Write-Host $uvOutput -ForegroundColor DarkGray
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue