Skip to content

fix(installer): finish a silent re-install over an existing install - #28469

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/27748-windows-reinstall-stall
Nov 11, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/27748-windows-reinstall-stall

Conversation

@dodgeblaster

@dodgeblaster dodgeblaster commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Does not change the installer's running-app detection (that is a separate PR).
  • Does not change what a visible (non-silent) install shows or does.
  • Does not bump or patch the pinned electron-builder dependency beyond the existing extract-step patch.
  • Does not change the fresh-install ceiling or the gateway-readiness checks.

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:

  1. The hang is a dialog. The previous version's uninstaller failed, and electron-builder's handleUninstallResult (installUtil.nsh) then showed "Failed to uninstall old application files. Please try running the installer again.: 2" with no /SD default. NSIS still displays such a box in a silent install, so an unattended run waits forever.
  2. Why the uninstaller failed. Run with --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.sh build_backend_windows, run by build-windows.yml) already prunes every __pycache__ and the tests/test trees 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__ and tests/, so the over-long path existed only in build.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.nsh defines customUnInstallCheck and customUnInstallCheckCurrentUser, which handleUninstallResult runs instead of its own body. Both carry that body with /SD IDOK on 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 as build_backend_windows, before the precompile pass: every __pycache__, the tests/test trees below site-packages, and the same stdlib and platform directories. This keeps the builtin apps' test bytecode out of the Windows bundle. MANIFEST.in and the sdist/wheel contents are unchanged: its note says in-package tests/ is deliberately not pruned (code_review_sage and issue_radar ship theirs) and that changing it belongs in its own change.
  • packaging/check_windows_path_budget.py fails 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\Temp 19), minus 25 for the uninstaller's \nsaXXXX.tmp\old-install\ (NSIS's GetTempFileName uses a three-letter ns<a-z> prefix, up to four hex digits and .tmp). build.yml runs it on the payload before the installer is built; test-windows-installer.ps1 runs it on the installed tree with the bundled interpreter (-B, so measuring writes nothing).
  • .github/scripts/test-windows-installer.ps1 drops 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.
  • The job's timeout-minutes moves 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 that build.yml's prune names every directory build_backend_windows removes and runs before the precompile pass. Mutants checked: > changed to >= in the comparison fails the at-budget test; dropping Lib\tkinter from 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 IDOK or 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.
  • Lint: black, isort, flake8, mypy on the new Python files; check_comment_history.py against origin/main passes.
  • scripts/local-gate.py ran with a borrowed virtualenv (this worktree has none) and reported failures in unrelated suites (file_explorer, design_tweak, dashboard gallery, a missing h2 module); 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 81d312b02237ce79693638f708bfbaebe9d88e81 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The NSIS /SD IDOK hook fixes the hang at its cause, and the CI prune fixes the path that made the old uninstall fail. One note: the prune list now exists in two places.

Notes

  • Item 2 — duplicate of packaging/build-desktop.sh build_backend_windows: the PowerShell prune in build.yml copies the release prune list instead of using it, and only test_the_ci_payload_is_pruned_like_the_release_payload keeps the two lists matched. The existing comment calls build.yml's assembly "the SAME assembly packaging/build-desktop.sh's build_backend_windows performs", so the duplication started before this PR. This PR adds one more copied list (1 more pattern). Subtraction: when the twin assembly goes away, delete the PowerShell list along with it.

What this change ships

Inventory (7 items) — 6 justified

Intent: a silent re-install or update over an existing Windows install finishes, or fails fast, instead of hanging. FIX.

  1. When the old version's uninstall fails, a silent install now exits 2 instead of waiting on a dialog nobody can see — justified
  2. The CI Windows payload now drops __pycache__, tests/test and the stdlib/platform directories, as the release build does — duplicate of packaging/build-desktop.sh prune list
  3. The build fails when a payload path is more than 186 characters below the install root — justified
  4. The installed tree is measured against the same budget before the re-installs run — justified
  5. The Windows job now re-installs silently with nothing running and over the running app — justified
  6. A re-install beside a running sibling "Nightly" copy, which must finish but whose survivors are only reported — justified
  7. The Windows job timeout goes from 20 to 30 minutes — justified

[FIRST-PRINCIPLES-REVIEWED] 81d312b

Description read

[DESCRIPTION-READ] e8925fd63d685c45052e79ee7149e946fb5b9548b2330ed49428da31eb996aec

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 81d312b02237ce79693638f708bfbaebe9d88e81 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 /SD IDOK default.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 81d312b02237ce79693638f708bfbaebe9d88e81 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The prune now exists twice, once in build.yml PowerShell and once in build-desktop.sh build_backend_windows, and only a test keeps them aligned. Having both call one shared prune script, as precompile_windows.py already is, would remove the second copy and the need for the parity test.
  • An electron-updater update whose previous-version uninstall fails will now exit 2 without telling the user. That beats hanging, but nothing in the app surfaces the failure. It is worth a follow-up issue so the auto-update path shows it.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 81d312b02237ce79693638f708bfbaebe9d88e81 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 81d312b

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 81d312b02237ce79693638f708bfbaebe9d88e81 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 81d312b02237ce79693638f708bfbaebe9d88e81 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 81d312b

Verdict parsed from the review's SHA-scoped output markers for commit 81d312b02237ce79693638f708bfbaebe9d88e81.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 81d312b02237ce79693638f708bfbaebe9d88e81 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 2, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/27748-windows-reinstall-stall branch from 8c0414b to 22c354a Compare November 2, 2026 21:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 2, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/27748-windows-reinstall-stall branch from 22c354a to 645be13 Compare November 9, 2026 18:22
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 9, 2026
@dodgeblaster dodgeblaster changed the title fix(installer): stop a silent re-install hanging over an existing install fix(installer): finish a silent re-install over an existing install Nov 9, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 9, 2026
@dodgeblaster
dodgeblaster force-pushed the fix/27748-windows-reinstall-stall branch from 645be13 to e1aedb9 Compare November 10, 2026 17:27
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 10, 2026
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
@dodgeblaster
dodgeblaster force-pushed the fix/27748-windows-reinstall-stall branch from e1aedb9 to 81d312b Compare November 10, 2026 21:31
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 10, 2026
@dodgeblaster
dodgeblaster marked this pull request as ready for review November 10, 2026 22:32
@dodgeblaster
dodgeblaster requested review from a team and KiroCrewCaptain as code owners November 10, 2026 22:32
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 10, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 11, 2026 05:41

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 precompiles lark_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.

@KiroCrewCaptain
KiroCrewCaptain merged commit 775ccc4 into main Nov 11, 2026
110 of 115 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/27748-windows-reinstall-stall branch November 11, 2026 05:42
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows silent re-install over an existing install stalls past 300s on the CI runner

2 participants