fix(cli): replay snapshot from latest-installed version, not new version#77
Merged
dipto0321 merged 1 commit intoJul 3, 2026
Merged
Conversation
`runUpgrade` snapshots each *previously installed* Node version's
global npm packages, then called `packages.Restore(ctx, mgr, *v)`
for each **newly installed** version. Since snapshots are keyed by
`<mgr>-<oldVersion>.json` (e.g., `fnm-20.10.0.json`) and `Restore`
looks up by the exact same key, the restore step read a file that
didn't yet exist (`fnm-20.11.0.json`) — its wrapped "read snapshot:
open …: no such file or directory" was swallowed by the loop's
`cmd.Printf("Warning: …")`, silently no-op'ing the package
migration on every upgrade.
Resolve the snapshot path the same way the sentinel block does
(latest-installed-version key, kept in a single local variable
shared between the sentinel arm and the restore step) and replay
via `packages.RestoreFromSnapshot(ctx, restoreSnapshotPath)`.
The user's global packages now carry forward to the new default
exactly once.
Refs #42
Co-Authored-By: puku-ai-2.8 <noreply@puku.sh>
|
✔️ cf9c75d - Conventional commits check succeeded. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The upgrade loop's restore step was looking up its snapshot by the new installed Node version, but snapshots are written for the previously installed versions. The lookup missed every time, the wrapped
read snapshot: open …: no such file or directoryerror was swallowed behindcmd.Printf("Warning: …"), and the package migration silently no-op'd for every new install. The fix resolves the snapshot path the same way the sentinel block already does (latest-installed-version key) and replays viapackages.RestoreFromSnapshot(ctx, restoreSnapshotPath)— globals now carry forward to the new default exactly once.Closes #42.
Linked issues
Type of change
fix— bug fix (PATCH bump)Checklist
fix(scope): subject)make cilocally and it passes (fmt, vet, test pass locally;make lintfails on the v2→v1 schema mismatch tracked in build(lint): .golangci.yml v1 schema incompatible with golangci-lint v2 (brew installs v2, make lint fails to even parse config) #62 — pre-existing onmain, independent of this fix; CI runs golangci-lint v1.64.8 per.github/workflows/ci.ymland will parse the config fine)docs/, inline godoc)Scope notes
Out of scope (separate issues, deliberately not touched here):
ltsJSON union bug ininternal/node/dist.go— already fixed in PR feat(cli): implement end-to-end upgrade command #20 (merged).Current()failure leaving active Node unprotected from cleanup — separate issue.--yesvs--no-cleanupprecedence — separate issue.Screenshots / output
The user-visible change is: previously, after a
nodeup upgrade, the user got an empty new Node with no globals. Now, the upgrade prints no migration output (matches old behaviour on success) but actually installs the carried-forward globals against the freshly-set-default Node. Verification path:npm ls -g --depth=0after upgrade will now show the same package list as before upgrade, instead of being empty.