Repository navigation
fix(installer): stop false 'cannot be closed' on a sibling install - #22557
dodgeblaster wants to merge 1 commit into
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The PR adds no new or changed control or text. The installer reuses electron-builder's own [UX-REVIEWED] f99fe4e Description read[DESCRIPTION-READ] e27ff757373bb5e27b0363173245f76802b4323e10a3c19df6c4a3762c7c2bbb 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix works at the mechanism level: it narrows the predicate behind the template's own override hook. One rider, the Notes
What this change shipsInventory (6 items) — 4 justifiedIntent: on Windows, install or update KiroCrew without a false "cannot be closed" prompt when a sibling or prefix-sharing process is running. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] f99fe4e Description read[DESCRIPTION-READ] bcebe52cd48fbcc25ba737418aef8455eb5ca311c065900d21269c2ebcc40cbc That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change overrides the running-app check through electron-builder's own Notes
[DESIGN-REVIEWED] f99fe4e Description read[DESCRIPTION-READ] 6f21be3ff101c0c0d17dfe9ba3e78480ac99eccb3cf2f9e35b8477b03c6302f2 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: |
2dd38f5 to
46ce331
Compare
46ce331 to
c4752d7
Compare
|
|
|
|
|
|
5e94351 to
7b2e9ef
Compare
|
|
|
|
|
|
|
|
|
|
|
HOLD, reviewed at 21ba613. Two things keep this from an approval:
Before approval, the author's own recommended hand test on Windows should be done: a — crew-pr-reviewer (r141) |
|
@buluoray could you take another look when you have a moment? Your change request (on 4516af7) asked for runtime evidence that the held-exe stall was not the new predicate missing the running exe. At head 21ba613 the author ran it on the Windows runner and reported back in the thread:
All checks are green at this head and the branch is mergeable. Your review is the open blocker, so a re-review (or a note on what is still missing) would let this move. Thanks. |
bolichen97
left a comment
There was a problem hiding this comment.
Approving head 21ba613. The gate shows 96 checks passed, none red or pending, including the Windows installer build.
What I checked in installer.nsh:
- It uses electron-builder's own override hook.
customCheckAppRunningtakes the!ifmacrodefbranch, so the pinned dependency is untouched. It sits outside!ifndef BUILD_UNINSTALLER, so the uninstaller that an update runs gets the same check. - The predicate matches only this install's own paths:
$INSTDIR\${APP_EXECUTABLE_FILENAME}exactly, or anything under$INSTDIR\resources\. AKiroCrew Nightlysibling and an unrelatedKiro-Cli\kiro-cli.exeunder a wider root no longer match, while a real install at any root, including a/Droot, still does. Find and kill use the same predicate. - A single process now counts. The
@(...)around the match fixes Windows PowerShell 5.1 reading one CimInstance's.Countas nothing, which would have let the installer write over a running app's locked files. The thread traces the held-exe stall on the earlier head to this. - The quoting is safe.
KiroPsSingleQuotedoubles apostrophes before$INSTDIRgoes into the single-quoted PowerShell literal, so a path likeO'Briencannot break parsing and read as "not running". - The retry, kill and prompt flow mirrors upstream step for step. The no-PowerShell
tasklistfallback is upstream's, unchanged.
The installer only stops matching processes it never owned. It adds no new restriction.
|
Thanks for chasing this down on the real Windows runner. The review found no blocking problem on this head. It still needs a human before it can merge, for two reasons:
What the review checked on this head:
Done well: the Windows harness runs the PowerShell text that ships, read straight out of installer.nsh. It does not test a copy. Optional:
|
21ba613 to
3bcc25a
Compare
3bcc25a to
54cf5c0
Compare
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. Overrides electron-builder's running-app check through its customCheckAppRunning hook. A process now counts as this install's only if its path is exactly $INSTDIR\KiroCrew.exe or is under $INSTDIR\resources, so a sibling like 'KiroCrew Nightly' or another product under a widened root no longer triggers the false 'cannot be closed' prompt. The retry/kill/prompt flow is copied from upstream and pinned by tests. The app ships nothing outside resources\ (no extraFiles), so the narrower match cannot miss a genuine running install. The @() wrap fixes upstream missing an app that runs as one process. The macro and its helpers are compiled into both the installer and the uninstaller. Apostrophes in the install path are escaped correctly. There are source-contract tests plus a Windows step that runs the shipped check against live processes. No regression or fail-open path found. The remaining risk is whether it compiles against the pinned template, which the pending Windows build job checks. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
The Windows installer reported "KiroCrew cannot be closed. Please close it
manually and click Retry to continue." on machines where no KiroCrew owned by
this install was running.
electron-builder's own _CHECK_APP_RUNNING (pinned 26.15.3) decides "is the app
running?" with a bare PowerShell prefix test,
`$_.Path.StartsWith('$INSTDIR', 'CurrentCultureIgnoreCase')`, interpolating
$INSTDIR with no trailing separator. A per-user stable install at
%LOCALAPPDATA%\Programs\KiroCrew therefore matches a running
%LOCALAPPDATA%\Programs\KiroCrew Nightly\KiroCrew.exe (the documented
side-by-side nightly channel), and with a widened $INSTDIR/InstallLocation the
same prefix reaches an unrelated %LOCALAPPDATA%\Kiro-Cli\kiro-cli.exe. The
installer then tries to kill a process it must not touch, fails, retries, and
raises $(appCannotBeClosed).
Define a customCheckAppRunning macro in website/electron/build/installer.nsh --
the override point CHECK_APP_RUNNING prefers via !ifmacrodef -- mirroring
upstream's retry/kill/prompt flow exactly, with one change: the PowerShell find
and kill predicates match only this install's own paths, a process whose path
is $INSTDIR\${APP_EXECUTABLE_FILENAME} or lies under $INSTDIR\resources\. Those
hold at any install root, so a genuine KiroCrew is still detected wherever it
was installed, while a sibling channel and an unrelated product under a widened
root match neither. The find predicate wraps its matches in @(...) before .Count: under
Windows PowerShell 5.1 a filter yielding exactly one process gives a bare
object with no .Count, so upstream's `(...).Count -gt 0` reads an app running
as a single process as not running. $INSTDIR's apostrophes are doubled before it is placed in
the single-quoted PowerShell literal. The macro and its helpers compile into
both the installer and the uninstaller, so the uninstaller a silent update
re-run invokes uses the same check. The PowerShell-unavailable fallback keeps
upstream's exact tasklist probe on KiroCrew.exe. Defining the hook makes the
template skip its own getProcessInfo.nsh include and `Var pid`, so installer.nsh
pulls both in.
packaging.running-app.test.js (split out of packaging.test.js for the
line cap; normalizedNsisBlock moves to packaging-test-helpers.js) pins the hook, the own-path predicates, the escaping, the
both-builds placement, the upstream retry flow, and how the Windows harness
reads each probe program from its macro. test-windows-installer.ps1 runs the
shipped predicate and electron-builder's under Windows PowerShell 5.1 against a
held running KiroCrew.exe (ours must see it as a single process) and two held
sibling copies (electron-builder's must match them, ours must not).
It runs after the silent re-install cases #28469 added and reuses their
held-process helpers unchanged.
Fixes #16745
54cf5c0 to
f99fe4e
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at f99fe4e. I read the whole diff, tests included. The predicate change in installer.nsh and the new runtime section in test-windows-installer.ps1 look right, and the new section passes on this head's "Build Windows Installer (x64)" run. With this install's app running as one process, the shipped KiroFindAppProcess program exits 0. With only the KiroCrew Nightly sibling running, it exits 1, while electron-builder's FIND_PROCESS exits 0.
I'm holding my approval for one line in the same job log, from the re-install cases that run just before that section:
Re-install beside a running sibling completed in 48.73 seconds.
Re-install beside a running sibling left 0 of its 2 processes running.
The harness logs this count but does not assert it. Read with the PR's goal, it says the silent /S re-install of this build still ended both held KiroCrew Nightly\KiroCrew.exe processes. Nothing else in that case stops them before the count; the finally that does runs after it. If the new check ignores the sibling, something else on the update path still closes it: the old uninstaller run under /S, the tasklist/taskkill image-name fallback, or another step. In the field, that would mean a stable update still closes a running Nightly. That is the third option in the earlier change request, whether a running KiroCrew Nightly sibling is left alone while the install completes.
Could you check which step ends the sibling processes? Then either fix it, or explain why it is expected and turn that line into an assertion that the sibling survives. I'll re-review as soon as that is in.
Problem / Motivation
Goal: The Windows installer stops claiming "KiroCrew cannot be closed" when no KiroCrew owned by this install is actually running.
On a machine updating or installing KiroCrew, the installer could show "KiroCrew cannot be closed. Please close it manually and click Retry to continue." even on a freshly rebooted machine where KiroCrew was never launched — blocking the install until the user manually ran the uninstaller.
Why it matters
A user cannot finish an install or update while the false prompt stands, with no running KiroCrew to close. It fires specifically when a side-by-side nightly channel, or another product whose path shares the prefix, is running — the common side-by-side-install case this project supports.
Not a goal
%TEMP%\~nsu.tmpuninstaller remnant the original report mentioned — that is NSIS's normal uninstaller copy, not a cause of this prompt.What changed (motivation → approach → change)
The prompt is raised by electron-builder's own running-app check. That check asks PowerShell whether any running process's path begins with the install directory, but interpolates the install directory with no trailing separator:
$_.Path.StartsWith('$INSTDIR', ...). So a stable install at%LOCALAPPDATA%\Programs\KiroCrewmatches a running%LOCALAPPDATA%\Programs\KiroCrew Nightly\KiroCrew.exe, and a widened install location reaches even an unrelated%LOCALAPPDATA%\Kiro-Cli\kiro-cli.exe. The installer then tries to kill a process it must not touch, fails, and shows the "cannot be closed" prompt.The check prefers a
customCheckAppRunningmacro when one is defined and otherwise falls back to its own. This adds that macro inwebsite/electron/build/installer.nsh, mirroring the upstream retry/kill/prompt flow exactly, with one change to the match: instead of "any process whose path starts with the install directory", the PowerShell find and kill predicates match only this install's own paths — a process whose path is exactly$INSTDIR\${APP_EXECUTABLE_FILENAME}(the app window) or lies under$INSTDIR\resources\(the bundled backend). Those are the app's own locations at any install root, so a genuine Kiro Crew is still detected wherever it was installed (a registered older root, a/Droot, or the default), while a sibling channel (...\KiroCrew Nightly\KiroCrew.exe) and an unrelated product under a widened root (%LOCALAPPDATA%\Kiro-Cli\kiro-cli.exe) are neither path and no longer match. The find predicate also wraps its matches in@(...)before.Count: under Windows PowerShell 5.1 (the interpreter the installer runs) a filter yielding exactly one process gives a bare object with no.Count, so upstream's(...).Count -gt 0misses an app running as a single process and the installer then extracts over its locked files. On the Windows runner upstream's check misses a single heldKiroCrew.exeand ours sees it.$INSTDIRis interpolated into a single-quoted PowerShell literal, so its apostrophes are doubled first (aC:\Users\O'Brien\...install must not break PowerShell parsing). Without PowerShell, the match keeps the upstream exacttasklistprobe onKiroCrew.exe;tasklistfilters by image name only, so that fallback is upstream's own behavior (unchanged, and only reached when PowerShell is unavailable). The macro and its helpers are placed so electron-builder compiles them into both the installer and the uninstaller — the uninstaller's running-app check (which a silent update re-run invokes) would otherwise fall back to the buggy upstream prefix. Defining the macro makes the template skip its owngetProcessInfo.nshinclude andVar pid, so the file pulls both in. The predicate is covered by source-contract tests inpackaging.test.jsand, on the real Windows artifact, by.github/scripts/test-windows-installer.ps1, which runs the shipped predicate against live processes (see Tests).Backwards compatibility
Compatible: the macro only narrows which running processes count as "this install"; it adds no required input and changes no stored value. An install with a genuinely running KiroCrew behaves exactly as before.
Removes nothing: no path, record, key, or public function is hidden, deleted, or tightened — the change is confined to the installer's running-app detection.
Tests
website/electron/test/packaging.running-app.test.jsadds a suite that (split out ofpackaging.test.jsto keep that file under the 2,000-line cap, with the sharednormalizedNsisBlockhelper moved topackaging-test-helpers.js):customCheckAppRunningoverride hook and the upstream dispatch it relies on, and that the file re-includesgetProcessInfo.nsh/Var pid;$INSTDIR\${APP_EXECUTABLE_FILENAME}or under$INSTDIR\resources\) against one escaped root, with no product-leaf guard;'→'') and anO'Brienround-trip;D:\Tools\Kiro(both detected), a siblingKiroCrew Nightly, a widened root reachingKiro-Cli, unrelated software at the same root, nothing running, and a stale/dead or reused PID;Sleepwaits (the exact300, 1000, 300, 1000, 2000sequence) and that noSleepor NSD timer appears elsewhere in the installer;appCannotBeClosedflow, so an electron-builder bump that changes either breaks a test;tasklistmatch;getProcessInfo.nshandVar pidsit outside every!ifblock (compiled into both the installer and uninstaller builds) whilecustomInitstays installer-only, so the uninstaller cannot regress to the upstream check;.github/scripts/test-windows-installer.ps1(theBuild Windows Installer (x64)job) runs the shipped check on the installed artifact, under Windows PowerShell 5.1 (the interpreter the installer uses), with no installer involved. It readsKiroFindAppProcess's PowerShell program frominstaller.nsh, and electron-builder'sFIND_PROCESSprogram from the pinned template, and holds the installedKiroCrew.exerunning as a timer underELECTRON_RUN_AS_NODE(image path verified):<install dir> Nightly: electron-builder's reports them (the false match, reproduced on the runner) and ours does not.This section runs after the silent re-install cases #28469 added to the same script (nothing running, the app running, a sibling running), and reuses their held-process helpers unchanged.
Manual verification
The check runs against live processes on a real Windows runner in CI (above). Not covered by CI: the installer closing a running app and completing a re-install (blocked by #27748), a real interactive app session rather than the held process, and an install whose previous version predates this fix (its old uninstaller still carries the upstream check, see Not a goal). A hand test on Windows is recommended before approval: with a stable install running,
/Sre-install closes it and completes; with aKiroCrew Nightlysibling running, the install completes and leaves it alone. The PowerShell-unavailabletasklistfallback (image-name-only, upstream's own) is not runtime-exercised.Screenshots / video
N/A — this changes the NSIS installer's running-app detection, not any dashboard frontend surface (
website/src/). No rendered pixel changes.Related Issues
Fixes #16745
Pattern harvest
Rule candidate: review-prompt
Pattern: a "is this process/path one of ours?" test written as a directory-prefix match (
StartsWith/startswith) matches siblings and, under a widened root, unrelated products; match the component's OWN known paths (its executable, its resource subtree) instead, which holds at any install root.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)