Repository navigation
fix(installer): skip the payload download when the install is current - #2437
Conversation
yuezengwu
left a comment
There was a problem hiding this comment.
Please use consistent completeness checks for the fast path and for reusing an extracted version. I ran all 46 portable-builder tests successfully, then reproduced two false-success cases using the same local fixture:
- Remove
current/INSTALL.jsonand rerun.installed_portable_versionstill returns the release version, so the installer exits 0 and claims the payload was skipped without restoring metadata that the portable updater reads. - Remove
current/VERSIONand rerun. The fast path correctly declines, but the reuse check accepts the old version directory and discards the fresh extraction. The installer exits 0 withVERSIONstill missing, so later reruns fetch the payload again.
Please require both metadata files before skipping or reusing a version, validate the candidate before replacing an existing version directory, and cover both missing-file cases alongside the missing-runtime test.
Re-running install.sh on an up-to-date machine downloaded the full portable payload (tens of MB with the bundled Node runtime) and then discarded it, because the version check only happened after extraction. The installer is the documented install-or-upgrade path, so a re-run must be cheap. Resolve the installed version from $PREFIX/current before the payload step and exit after wiring PATH and the service when everything is already in place: the version file, the bundled runtime, the app entry, and both shims. Any missing piece falls through to the normal install, so the same code path repairs an interrupted install instead of skipping it. An existing version directory is now only reused when it is complete, since the fast path already handles the complete case; an incomplete one is re-extracted rather than failing the pre-commit smoke check later. A local.* dev build compares unequal to every released version, so the installer would silently replace it. Warn before doing that; `upgrade` treats local builds as ahead and refuses instead.
The two checks disagreed: the fast path required VERSION but not INSTALL.json, and reuse required INSTALL.json but not VERSION. Both half-states are false successes — a prefix with no INSTALL.json skipped the install even though the portable updater reads it, and a version directory with no VERSION was reused, discarding the fresh extraction and leaving the file missing. Both now call portable_version_dir_complete(), which requires VERSION, INSTALL.json, the bundled runtime and the app entry. The incomplete directory is also replaced only after the extracted candidate has passed its INSTALL.json validation, so a bad download cannot cost the directory already on disk. The repair test is now a three-case table (runtime, VERSION, INSTALL.json), and each case fails when its check is removed from the shared predicate.
88780ea to
e8fd61f
Compare
|
You were right on both counts — the two checks had drifted apart, and each half-state is a false success. Fixed in
Negative controls, reverted one at a time: dropping the |
The repair path now deletes the incomplete version directory only after the extracted candidate passes its INSTALL.json validation. A stale candidate whose metadata disagrees with the manifest must fail the install without wiping what an earlier attempt left behind; without the reorder the existing directory is gone before validation runs.
|
One more commit since that reply: CI is green on |
yuezengwu
left a comment
There was a problem hiding this comment.
The shared completeness check fixes both missing-metadata cases, and all 49 checked-in portable-builder tests passed locally. The same-version repair can still replace a working CLI before the candidate passes the runtime smoke check. After installing the fixture, I removed only current/INSTALL.json and confirmed the existing shim still returned its version. A same-version candidate with matching metadata then failed the smoke check. The installer exited 1, and the same shim now failed because current already pointed at the replacement files.
Please run the runtime smoke check against the candidate directory before removing or replacing the existing directory, and add a same-version repair regression that verifies the old shim still works after the candidate fails.
A same-version repair swaps files into the live version directory, so running the runtime check after the swap meant a payload that cannot start replaced a working CLI: the installer exited 1 and the existing shim was already pointing at files that never ran. The check now runs against the candidate directory (the fresh extraction, or the reused directory) before anything on disk is removed or replaced. The regression installs the fixture, drops current/INSTALL.json so the next run takes the repair path, points the fixture at a payload whose runtime fails, and asserts both the failure and that the old shim still prints its version. Restoring the old order turns that assertion into an empty string.
|
Correct, and the order was the whole bug: a same-version repair writes into the version directory Fixed in
50/50 portable-builder tests pass; |
yuezengwu
left a comment
There was a problem hiding this comment.
The installer now runs the candidate runtime smoke check before replacing the existing directory. The new regression confirms that a failed same-version repair leaves the previous shim runnable. All 50 portable-builder tests passed locally, including the missing-file repair cases, and the installer passed the shell syntax check.
Re-running
install.shon an up-to-date machine downloads the whole portable payload — tens of MB, bundled Node runtime included — and then throws it away: theversions/<version>check happens after extraction, so the download has already completed. The installer is the documented install-or-upgrade path, so a re-run has to be cheap.Summary
$PREFIX/currentbefore the payload step, and exit right after wiring PATH and the background service.current/VERSION, the bundled runtime, the app entry, and both shims — and the shims must point at this prefix, so re-running with a different--prefixis not mistaken for an installed machine.versions/<version>directory was reused unconditionally, so an install that had lost its runtime died in the pre-commit smoke check instead of being repaired. It is now reused only when complete, and re-extracted otherwise.local.*dev builds compare unequal to every released version, so the installer would replace them silently. It now warns first;upgradetreats local builds as ahead and refuses.Validation
pnpm checkandpnpm typecheckpass.apps/cli/tests/portable-builder.test.ts: 46 passed, including three new cases:already installed; skipped the payload download, so no fetch happened;current/nodereinstalls and restores the runtime;local.20260101→1.2.3prints the replacement warning and movescurrent.dash -n(Linux's/bin/sh) parses the script, and the two main scenarios were re-run underdash, not just macOS'ssh.Change Surface
Notes
install.shon a current machine no longer fetches the payload; an incompleteversions/<version>directory is now replaced instead of reused; replacing alocal.*build is announced.apps/cli/tests/portable-builder.test.ts.npm install -gself-update ([Bug] Daemon auto-update is not restart-safe: killed npm install corrupts node_modules and crash-loops the whole host #2394) is a separate, non-atomic path and is untouched.curl | shflow — the channel rewrite inrenderInstallerForChanneldoes not touch the new code, and the tests drive the same download branch throughFIRST_TREE_PORTABLE_DOWNLOAD_BASE_URL=file://.Fixes #2088.