Repository navigation
fix(installer): finish a silent re-install over an existing install - #28469
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The NSIS Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: a silent re-install or update over an existing Windows install finishes, or fails fast, instead of hanging. FIX.
[FIRST-PRINCIPLES-REVIEWED] 81d312b Description read[DESCRIPTION-READ] e8925fd63d685c45052e79ee7149e946fb5b9548b2330ed49428da31eb996aec That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff adds no visible control. The visible installer shows the same upstream "$(uninstallFailed)" box as before, and the only change is the silent-mode [UX-REVIEWED] 81d312b Description read[DESCRIPTION-READ] 45a2b8dec54cae7ececac7a8ac2bcade96d4d83a3535c964f78521a8b04a0a24 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The silent re-install hang now ends with exit code 2, CI's payload is pruned the same way the release build is, and a parity test keeps the two prune lists in step. Notes
[DESIGN-REVIEWED] 81d312b Description read[DESCRIPTION-READ] e38b0c5af0895746b7081a615a4adc22468bde4552f29dd0138ddb653f869528 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
8c0414b to
22c354a
Compare
22c354a to
645be13
Compare
645be13 to
e1aedb9
Compare
A silent re-install runs the previous version's uninstaller first, with --updated, which renames every installed file into %TEMP%. The CI payload shipped pip's bytecode for the in-package test trees, whose deepest file moved to a path past MAX_PATH, so that uninstaller failed with code 2 every time. electron-builder then showed its "uninstall failed" box with no /SD default, and NSIS displays it even in a silent run, so the installer waited forever. - installer.nsh defines customUnInstallCheck / customUnInstallCheckCurrentUser with electron-builder's body plus /SD IDOK on the box: a silent run logs the code and exits 2, a visible run is unchanged. - build.yml's Windows payload assembly applies the same prune as build-desktop.sh's build_backend_windows (every __pycache__, the tests/test trees below site-packages, the stdlib and platform trees the app never loads) before precompiling the gateway closure. - packaging/check_windows_path_budget.py fails a payload with a path longer than 186 characters below the install root (259 usable, minus a 48-character %TEMP% for a 20-character profile folder, minus the uninstaller's 25-character \nsaXXXX.tmp\old-install\ move directory). build.yml runs it on the payload and the installer harness on the installed tree. - test-windows-installer.ps1 re-installs silently with nothing running, over the running app and beside a running sibling copy, each inside a 240-second ceiling; the job's cap moves from 20 to 30 minutes to hold them. MANIFEST.in and the sdist/wheel contents are unchanged. Fixes #27748
e1aedb9 to
81d312b
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Verified on this head: the new customUnInstallCheck and customUnInstallCheckCurrentUser hooks copy the pinned electron-builder 26.15.3 handleUninstallResult body exactly and add only /SD IDOK. The Build Windows Installer (x64) job passed with the path budget at 180 of 186, and all three silent re-install cases finished in 51 to 58 seconds against a 240 second ceiling. The update path in this app calls quitAndInstall(false, true), so it is not silent and still shows the box as on main. The claimed mutants (> to >=, dropping Lib\tkinter, removing /SD IDOK or renaming a hook) each turn a test red.
Done well: the fix uses electron-builder's own override hooks instead of patching the template, and packaging.test.js pins both the upstream dispatch and the replaced body, so a future electron-builder bump that changes either one fails a test.
Optional:
- The release Windows bundle installs
[feishu]and precompileslark_oapi, which gives pyc paths up to 201 characters, and the new gate runs only on the CI payload. Consider fixing the body sentences that say release-bundle users are not affected, and opening a follow-up issue for that bundle. - The exit 2 half of the Goal is pinned only as text. A stage that forces the old uninstall to fail and asserts exit code 2 would give it a runtime check.
- #22557 adds the same held-process helpers at the same place in
test-windows-installer.ps1. Name a merge order in both bodies so the second PR keeps the first one's helpers and adds no copy.
Problem / Motivation
Goal: A silent re-install over an existing Windows install no longer hangs: it finishes, or fails fast with an exit code. The Windows installer job proves this with re-install smoke cases.
On the Windows CI runner, running the freshly built installer a second time over an existing install (
<Setup>.exe /S /currentuser /D=<root>) does not finish within 300 seconds, even with nothing of Kiro Crew running. A fresh silent install of the same artifact finishes in about 60 seconds. When the ceiling hit, the installer process was alive, had no child processes, and nothing was running from the install tree.Why it matters
electron-updater applies an update by re-running the installer over the existing install, and scripted silent redeploys do the same. An installer that can wait forever with no visible cause blocks both. Because of the stall, the Windows job has no re-install coverage at all, so the running-app check and the previous-version uninstall path go untested on a real artifact.
Not a goal
What changed (motivation → approach → change)
Symptom: a silent re-install over an existing install never finished on the Windows runner. Two causes, both shown by the round-1 diagnostic on this PR:
handleUninstallResult(installUtil.nsh) then showed "Failed to uninstall old application files. Please try running the installer again.: 2" with no/SDdefault. NSIS still displays such a box in a silent install, so an unattended run waits forever.--updated, it renames every installed file to%TEMP%\nsaXXXX.tmp\old-install\<relative path>. The CI payload carried pip's bytecode for the in-package test trees; the deepest file sat 201 characters below the install root, so its moved path was about 265 characters, past MAX_PATH. The first failed rename aborts the uninstall with code 2.The release Windows build (
packaging/build-desktop.shbuild_backend_windows, run bybuild-windows.yml) already prunes every__pycache__and thetests/testtrees below site-packages before it precompiles only the gateway's import closure. So the 201-character file was in the CI payload (build.yml's assembly, which skipped that prune), not in released installers. Round 1's estimate that released updates fail for users with long usernames does not hold for the release bundle.In plain terms: the release Windows build (
build-desktop.sh) already prunes__pycache__andtests/, so the over-long path existed only inbuild.yml's CI payload and release-bundle users were likely not affected; this fix makes CI mirror the release prune and adds the path-budget check.Change:
website/electron/build/installer.nshdefinescustomUnInstallCheckandcustomUnInstallCheckCurrentUser, whichhandleUninstallResultruns instead of its own body. Both carry that body with/SD IDOKon the box. A silent run logs the uninstaller's code and exits 2; a visible run still shows the box and waits for OK..github/workflows/build.yml's Windows payload assembly now applies the same prune asbuild_backend_windows, before the precompile pass: every__pycache__, thetests/testtrees below site-packages, and the same stdlib and platform directories. This keeps the builtin apps' test bytecode out of the Windows bundle.MANIFEST.inand the sdist/wheel contents are unchanged: its note says in-packagetests/is deliberately not pruned (code_review_sageandissue_radarship theirs) and that changing it belongs in its own change.packaging/check_windows_path_budget.pyfails a payload with a path more than 186 characters below the install root. The arithmetic is in the script: 259 usable characters (MAX_PATH 260 minus the NUL), minus 48 for%TEMP%(C:\Users\9 + a profile folder of at most 20 +\AppData\Local\Temp19), minus 25 for the uninstaller's\nsaXXXX.tmp\old-install\(NSIS'sGetTempFileNameuses a three-letterns<a-z>prefix, up to four hex digits and.tmp).build.ymlruns it on the payload before the installer is built;test-windows-installer.ps1runs it on the installed tree with the bundled interpreter (-B, so measuring writes nothing)..github/scripts/test-windows-installer.ps1drops the round-1 diagnostic and re-installs silently in three cases: nothing running, over the running app (held as two processes, which the installer must close), and beside a running sibling copy in<install dir> Nightly. Each must exit 0 within a 240-second ceiling, keep the registration on the same root, keep the executable, and leave the user's pre-existing files alone. The ceiling is twice the slowest measured fresh install (98 s, the basis of$MaxInstallSeconds), 196 s, rounded up. The sibling case asserts only that the re-run finishes; whether the sibling's processes survive it is the running-app check's behaviour and is reported, not asserted.timeout-minutesmoves from 20 to 30: about 9 minutes to a booted installed gateway, plus up to 12 minutes for three re-installs at the ceiling, plus the uninstall.%TEMP%is not shortened for the harness: the budget is checked against a real-length one.Backwards compatibility
Compatible: a visible install, and a silent install whose previous-version uninstall succeeds, behave as before. A silent install whose previous-version uninstall fails now exits 2 instead of waiting on a hidden box.
Removes nothing from released installers: the CI payload's prune matches what the release build already does.
Tests
test/test_check_windows_path_budget.py(new): pins the 186 arithmetic; a path exactly at the budget passes; a path one character over fails and is named; the install-root prefix counts toward the budget; the unpruned test-bytecode file (201 characters) fails; an empty root fails. It also pins that both Windows jobs run the gate, and thatbuild.yml's prune names every directorybuild_backend_windowsremoves and runs before the precompile pass. Mutants checked:>changed to>=in the comparison fails the at-budget test; droppingLib\tkinterfrom the CI prune fails the parity test.website/electron/test/packaging.test.js: "reports a failed previous-version uninstall without blocking a silent install" pins the template's dispatch to both hooks, the upstream box they replace, and the hook bodies including/SD IDOK(removing/SD IDOKor renaming a hook fails it). New: "re-installs silently over the existing install in all three cases, under a stated ceiling" pins the three stages, the 240-second ceiling, the timeout and exit-code failures, and that the path gate runs before the first re-install. 54/54 pass.test_windows_installer_doc_contract.py,test_windows_installer_pr_gate.py,test_precompile_windows.py: pass.check_comment_history.pyagainst origin/main passes.scripts/local-gate.pyran with a borrowed virtualenv (this worktree has none) and reported failures in unrelated suites (file_explorer, design_tweak, dashboard gallery, a missingh2module); none of the failing files is touched by or related to this diff.Runtime evidence is the
Build Windows Installer (x64)job: the path gate's longest-path line, and the three re-install stages each logging "completed in N seconds".Proof: not provable -- other: NSIS installer, CI workflow and PowerShell harness, proven on the Windows runner; the one Python file is a build-time gate covered by its own tests
Manual verification
The Windows installer job on this PR is the verification surface; I cannot run Windows locally. A hand test of a silent re-install on a real Windows machine is recommended before approval.
Screenshots / video
N/A — this changes the Windows installer CI harness, not any dashboard frontend surface.
Related Issues
Fixes #27748
Sibling sweep
Swept: grep -n "MessageBox" over the pinned app-builder-lib NSIS templates for boxes with no /SD on a silent path
Sibling: website/electron/build/installer.nsh -- not affected -- its only MessageBoxes are guarded by IfNot Silent or run only from the visible wizard
Pattern harvest
Rule candidate: review-prompt
Pattern: an NSIS MessageBox reachable in a silent install without an /SD default blocks forever on an unattended machine; every box on a silent path needs /SD.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.