Skip to content

wpm update winuxcmd can leave command links on the previous image, silently #1206

Closed

Description

@caomengxuan666

What we see

After wpm update winuxcmd, a command link can be left on the previous winuxcmd.exe while the rest of the family is refreshed, and nothing reports it. Observed on a live install:

usr\bin\yes.exe        size 4,115,456   (the 1.1.12 image, mtime 2026-10-16 18:30)
usr\bin\winuxcmd.exe   size 4,119,040   (1.1.13)

The rest of the 178-name link family was on the current inode; only yes.exe had been left behind, hours after the update. wpm links rebuild --force repaired it in one pass (created=1 unchanged=177), so the link set itself is fine — it is the update path that leaves a name stale, silently.

Why it is invisible today

  1. apply_update() ends with rebuild_links(root, true, …) and returns its exit code, but the helper is launched detached (launch_apply_update → CreateProcessW(..., CREATE_NO_WINDOW, ...)) and its stdout/stderr are discarded — a failure inside the update produces no visible output anywhere.
  2. rebuild_links counts failures (links created=… unchanged=… failed=…) but never names the link that failed, so even a visible run cannot say which command is stale.
  3. auto_activate_bundled_winuxcmd (the check that would repair it on the next shell start) only verifies that a few required links exist — it does not compare identity — so one stale name never triggers the rebuild.

Reproducing it is a trap in itself

wpm update winuxcmd returns before the swap happens: the helper waits for the updating process to exit (WaitForSingleObject(parent, 30000)) and only then replaces the image and relinks. Auditing the link set immediately after the command returns shows the whole family as "stale", which is a false positive — I chased that for a while. Anything that verifies an update must either wait for the helper or check wpm version / the file identity again later. Worth saying in the guide.

Suggested fixes (in the order they pay off)

  1. Give the helper a log. Write its output to <root>\.wpm\logs\self-update.log (rotating, one file). Without this, every failure in this path is unobservable.
  2. Name the failing link and park instead of giving up. The remove_link_if_safe refusal path currently just increments failed; parking the name aside and linking over it (what package upgrades already do since fix(wpm): replace held payload files by parking them, not by refusing #1194) lets the update complete, and printing the name makes the residual failure actionable. (Patch in flight.)
  3. Verify after the swap. After rebuild_links, re-read the family and re-run once if any name still points at another inode; report the names if the second pass fails.
  4. Strengthen the activation spot-check (has_required_command_links) to compare file identity for a sample instead of testing existence, so a stale family self-heals on the next shell start rather than waiting for a manual links rebuild.

Acceptance

  • An update that cannot relink a name leaves a log line naming it, and the install reports the mixed state instead of exiting 0 silently.
  • After an update (waiting for the helper), every name in usr/bin that is a link to winuxcmd.exe shares its inode, verified by a test that stops a name from being replaced.

Activity

  1. added
    bug
    wpm
    packaging
    on Oct 17, 2026
  2. added 2 commits that reference this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpackagingwpm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions