fix(windows): kill hermes before recreating venv to release _bcrypt.pyd lock (#45120)

On Windows, native Python extensions such as _bcrypt.pyd are loaded as
DLLs by any running hermes process. When the installer tries to recreate
the venv (Remove-Item -Recurse -Force "venv"), Windows denies the delete
because the DLL is still mapped into the running process.

Add a taskkill /F /T /IM hermes.exe call before the Remove-Item so any
hermes process tree is stopped first, releasing the file lock. A short
sleep gives the OS time to unload the image before deletion proceeds.

This mirrors the existing force_kill_other_hermes() guard already present
in the --update flow (update.rs), applying the same pattern to the full
reinstall/repair path through install.ps1.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
leo4226 2026-06-15 04:27:00 +02:00 committed by GitHub
parent 8fe334b056
commit f795513782
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1431,6 +1431,15 @@ function Install-Venv {
if (Test-Path "venv") {
Write-Info "Virtual environment already exists, recreating..."
# On Windows, native Python extensions (e.g. _bcrypt.pyd) are loaded as
# DLLs by any running hermes process. Windows denies deletion of loaded
# DLLs, so kill any hermes.exe tree before removing the venv.
if ($env:OS -eq "Windows_NT") {
$myPid = $PID
Write-Info "Stopping any running hermes processes before recreating venv..."
& taskkill /F /T /IM hermes.exe /FI "PID ne $myPid" 2>$null | Out-Null
Start-Sleep -Milliseconds 800
}
Remove-Item -Recurse -Force "venv"
}