Merge pull request #48529 from kshitijk4poor/salvage-48372-eap

fix(install): relax EAP=Stop around native git/uv calls + fail-fast on uv venv failure (#48352, salvage of #48372)
This commit is contained in:
kshitij 2026-06-18 22:17:53 +05:30 committed by GitHub
commit 2fa16ec2d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 124 additions and 6 deletions

View file

@ -185,6 +185,18 @@ function Write-Err {
Write-Host "[X] $Message" -ForegroundColor Red
}
function Invoke-NativeWithRelaxedErrorAction {
param([scriptblock]$Script)
$prevEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
try {
& $Script
} finally {
$ErrorActionPreference = $prevEAP
}
}
# Inspect npm output for a TLS-trust failure and, if found, print actionable
# remediation. npm/Node surface corporate MITM proxies and missing root CAs as
# "unable to get local issuer certificate" / "self-signed certificate in
@ -1340,7 +1352,7 @@ function Install-Repository {
Write-Info "Trying SSH clone..."
$env:GIT_SSH_COMMAND = "ssh -o BatchMode=yes -o ConnectTimeout=5"
try {
git -c windows.appendAtomically=false clone --depth 1 --branch $Branch $RepoUrlSsh $InstallDir
Invoke-NativeWithRelaxedErrorAction { git -c windows.appendAtomically=false clone --depth 1 --branch $Branch $RepoUrlSsh $InstallDir }
if ($LASTEXITCODE -eq 0) { $cloneSuccess = $true }
} catch { }
$env:GIT_SSH_COMMAND = $null
@ -1349,7 +1361,7 @@ function Install-Repository {
if (Test-Path $InstallDir) { Remove-Item -Recurse -Force $InstallDir -ErrorAction SilentlyContinue }
Write-Info "SSH failed, trying HTTPS..."
try {
git -c windows.appendAtomically=false clone --depth 1 --branch $Branch $RepoUrlHttps $InstallDir
Invoke-NativeWithRelaxedErrorAction { git -c windows.appendAtomically=false clone --depth 1 --branch $Branch $RepoUrlHttps $InstallDir }
if ($LASTEXITCODE -eq 0) { $cloneSuccess = $true }
} catch { }
}
@ -1477,8 +1489,20 @@ function Install-Venv {
Remove-Item -Recurse -Force "venv"
}
# uv creates the venv and pins the Python version in one step
& $UvCmd venv venv --python $PythonVersion
# uv creates the venv and pins the Python version in one step. uv emits
# normal progress such as "Using CPython ..." on stderr; under Windows
# PowerShell 5.1 with EAP=Stop that stderr is a NativeCommandError unless
# we temporarily relax EAP and trust $LASTEXITCODE for real failures.
Invoke-NativeWithRelaxedErrorAction { & $UvCmd venv venv --python $PythonVersion }
# Relaxing EAP above means a *genuine* uv-venv failure (exit != 0) no longer
# aborts on its own. Capture $LASTEXITCODE immediately and fail fast, so the
# `venv` stage can't falsely report success (and Invoke-Stage can't emit
# ok=true) when the venv was never created.
$venvExitCode = $LASTEXITCODE
if ($venvExitCode -ne 0) {
Pop-Location
throw "Failed to create virtual environment (uv venv exited with $venvExitCode)"
}
# Neutralize any inherited UV_PYTHON (e.g. $env:UV_PYTHON = "3.14" left in
# the user's shell). uv honours UV_PYTHON over an existing venv for the
@ -1548,7 +1572,7 @@ function Install-Dependencies {
# in the wrong directory and imports fail with ModuleNotFoundError.
# (Mirrors the same flag in scripts/install.sh::install_deps.)
$env:UV_PROJECT_ENVIRONMENT = "$InstallDir\venv"
& $UvCmd sync --extra all --locked
Invoke-NativeWithRelaxedErrorAction { & $UvCmd sync --extra all --locked }
if ($LASTEXITCODE -eq 0) {
Write-Success "Main package installed (hash-verified via uv.lock)"
$script:InstalledTier = "hash-verified (uv.lock)"
@ -1623,7 +1647,7 @@ except Exception:
if (-not $skipPipFallback) {
foreach ($tier in $installTiers) {
Write-Info "Trying tier: $($tier.Name) ..."
& $UvCmd pip install -e $tier.Spec
Invoke-NativeWithRelaxedErrorAction { & $UvCmd pip install -e $tier.Spec }
if ($LASTEXITCODE -eq 0) {
Write-Success "Main package installed ($($tier.Name))"
$script:InstalledTier = $tier.Name