From f7955137828e43d26bab926f0aacc5302d5fa357 Mon Sep 17 00:00:00 2001 From: leo4226 <55195509+leo4226@users.noreply.github.com> Date: Mon, 15 Jun 2026 04:27:00 +0200 Subject: [PATCH] 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 --- scripts/install.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 1269bee8b6c..01125ff4a7e 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -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" }