Repository navigation
fix(wpm): name the command link a rebuild cannot replace, and park it instead of giving up - #1209
Merged
Merged
Conversation
… instead of giving up A stale command link - one left on the previous winuxcmd.exe by an update - is counted as a failure but never named, and `remove_link_if_safe` gives up on it without trying anything else, so the installation keeps running the older image for that one command and says nothing (#1206, observed as `yes.exe` on a live install, hours after the update). - A name that cannot be deleted is now *parked* first and linked over, the same move a package upgrade makes for a held payload file (#1194); if even the rename is refused, the message names the link and says what it means ("still points at the previous winuxcmd.exe") instead of leaving a bare count in the summary. - The guide documents that `wpm update winuxcmd` is asynchronous: the helper waits for the updating process to exit (up to 30 s) before swapping the image and relinking, so auditing versions or links immediately after the command returns can legitimately show the previous build. That window cost real time during the investigation; `wpm links rebuild --force` recreates the links from the installed image at any time. Tests: `wpm.links_rebuild_names_a_link_it_cannot_replace` holds a stale link without share-delete (so neither delete nor rename is possible), asserts the exit code and the named message, and that every other name still resolves to the current image. Full wpm suite green.
…, retry once Three gaps from #1206, all about an update that silently leaves a command on the previous image. - **The detached helper now has a log.** Its stdout/stderr were discarded, so a failure inside `apply_update` - including a relink that could not replace a name - produced no output anywhere. It writes to `<root>\.wpm\logs\self-update-<stamp>-<pid>.log`, the newest three are kept, and the "update staged" message names the file. - **The links are verified after the swap.** `finish_update` rebuilds them, re-reads the family, retries once, and reports the names that still point at the previous image. Previously a partial relink exited 0. - **`wpm links verify`** reports by path every command link that does not run the installed `winuxcmd.exe` - the diagnosis this whole investigation lacked; `wpm links rebuild --force` (already there) replaces them. Tests: `wpm.links_verify_names_stale_command_links` (clean installation verifies clean; one name pointed at another image is reported by path) and the earlier `wpm.links_rebuild_names_a_link_it_cannot_replace`. `wpm.*` 60/60, full suite 2849/2849 with the two known machine-local i18n failures.
caomengxuan666
added a commit
to unixwin/niubash
that referenced
this pull request
Oct 18, 2026
`has_required_command_links` only asked whether `ls.exe`, `cat.exe`, `grep.exe` and `ln.exe` exist, so a command link left on the *previous* winuxcmd.exe by an update satisfied it forever: activation then skipped the rebuild and that one command kept running an older build (observed as a stale `usr\bin\yes.exe` hours after the update - unixwin/WinuxCmd#1206). Compare identity instead: a required name must be the same file as this installation's `winuxcmd.exe`. When it is not, activation runs `wpm links rebuild --force` as before, which now also *names* the links it cannot replace (unixwin/WinuxCmd#1209). A stale name therefore heals on the next shell start instead of waiting for someone to notice. Test updated to match the contract it is asserting: names that are not links to the engine do not count, links to it do, and one name left on a different image is enough to ask for a rebuild.
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.
Part of #1206 (the naming/diagnosis half; the helper log and the post-swap verification stay in the issue).
Why
A command link left on the previous
winuxcmd.exe(observed asusr\bin\yes.exeon a live install, hours after an update) is counted in the summary but never named, andremove_link_if_safegives up on it without trying anything else. So an installation can be running two differentwinuxcmdbuilds, one command at a time, and nothing says so.What changes
'…' still points at the previous winuxcmd.exe) instead of leaving a barefailed=1in the summary.wpm update winuxcmdreturns before the swap: the detached helper waits for the updating process to exit (up to 30 s) and only then replaces the image and relinks. Auditing versions or links immediately after the command returns can legitimately show the previous build — that window cost real time during this investigation, so §4.3 of the guide now says it, and points atwpm links rebuild --force, which recreates the links from the installed image at any time.Verification
New test
wpm.links_rebuild_names_a_link_it_cannot_replace: a staleyes.exeis held withoutFILE_SHARE_DELETE, so neither delete nor rename is possible; the test asserts a non-zero exit, the named message, and that every other name still resolves to the current image while the held one does not.wpm.*→ 59 passed, 0 failed (the full filter).Also in this PR (second commit)
apply_updateproduced no output anywhere. It writes to<root>\.wpm\logs\self-update-<stamp>-<pid>.log, the newest three are kept, and the "update staged" message names the file.finish_updaterebuilds them, re-reads the family, retries once, and reports the names that still point at the previous image — previously a partial relink exited 0.wpm links verifyreports by path every command link that does not run the installedwinuxcmd.exe;wpm links rebuild --force(already there) replaces them.Test:
wpm.links_verify_names_stale_command_links(a clean installation verifies clean; a name pointed at another image is reported by path).wpm.*60/60; full suite 2897/2899 with the two known machine-local i18n failures.Not in this PR
has_required_command_linkscompares existence, not identity) is a niubash-side follow-up.