Skip to content

fix(winuxcmd): activation compares link identity, not existence - #401

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/activation-identity-check
Oct 18, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/activation-identity-check

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Closes the self-healing half of #1206 (the WinuxCmd side is #1209).

Why

has_required_command_links asked only whether four names exist:

["ls.exe", "cat.exe", "grep.exe", "ln.exe"].iter().all(|name| dir.join(name).is_file())

So a command link left on the previous winuxcmd.exe by an update satisfied it forever: activation skipped the rebuild, and that one command kept running an older build. That is exactly the live finding in #1206 — usr\bin\yes.exe on the 1.1.12 image while the rest of the family was on 1.1.13, hours after the update, with nothing reporting it.

What changes

A required name must now be the same file as this installation's winuxcmd.exe. When it is not, activation runs wpm links rebuild --force exactly as before — and that path now names any link it cannot replace (WinuxCmd#1209). A stale name heals on the next shell start rather than waiting for someone to look.

The identity helper is the one the shell-link work already uses (shell_links::same_file), now pub(crate), so there is one definition of "same file" on Windows (volume serial + file index) instead of a second copy.

Verification

command_links_are_required_before_skipping_activation now asserts the contract it is named for: 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.

cargo test -p niubash-runtime → 23 passed in winuxcmd::tests + shell_links::tests (515 filtered); cargo check --tests --target x86_64-unknown-linux-gnu clean (the cross-target job compiles this code on unix hosts).

Not here

  • The WinuxCmd side (naming the failing link, parking it, logging the helper, verifying after the swap) is #1209.
  • wpm links rebuild still does not refresh package shims (only the applet names); that belongs with #1207.

CI red-fix log (2026-10-18)

The three failing cross-target checks and the later build-and-test red were both moving-dependency fallouts, not product regressions in this branch; fixed on this branch in 1c33c1c (rebase) + f724aae (test rewrite).

  1. cross-target-check (musl, ohos) + cross-target-smoke — upstream rubash compile error. The Oct 17 run cloned rubash HEAD before 8d8537c6 ("allow the musl/ohos libc::time_t deprecation", rubash#782), and with setup-rust-toolchain's -D warnings the deprecation in printf/zone.rs:367 was a hard error on the musl-based targets (android/bionic and glibc hosts never see it). Fix: rebased onto master d60276e so CI clones the fixed rubash; no source change needed here. All three lanes went green on the next run.

  2. build-and-test after the rebase — expired test. rubash#759 item 4 (rubash master c6f4a9b3, landed between master's last green run and our re-run) deliberately removed the zsh setopt/unsetopt aliases (docs/builtins.md: 64 → 62 builtins), so rubash_setopt_is_visible_when_sourcing_startup_rc failed with setopt: command not found (exit 127). The pinned contract — option builtins are visible while the startup rc is sourced and their state survives into the live shell — is unchanged, so f724aae re-points the test at the bash-aligned shopt surface: -s batch form, -u, and the bare state listing, with default-off extglob/expand_aliases proving a real off→on transition and a set-then-unset dotglob covering -u. cargo test --test host_contract → 48 passed locally.

  3. build-and-test second round — same contract change, third surface. rubash#759 item 4 also shrank the live builtin inventory that CommandCompleter::get_builtin_commands() delegates to, so test_get_builtin_commands failed on commands.contains("setopt"). 8dc298f pins the new shape (shopt present, the zsh aliases absent) and swaps the empty-Tab suggestion entries setopt -> shopt / drops unsetopt, so Tab no longer offers a name that cannot resolve. (syntax_highlighting still lists the alias words cosmetically; left alone on purpose.)

No release.yml semantics and no GPL-licensed material are touched; the branch diff is the one source commit of this PR plus the two rubash#759 catch-ups above.

`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.
@caomengxuan666
caomengxuan666 force-pushed the fix/activation-identity-check branch from d888dfd to 1c33c1c Compare October 18, 2026 16:19
@caomengxuan666

Copy link
Copy Markdown
Member Author

CI red-diagnosis and fix note (rebased to master d60276e, pushed as 1c33c1c):

Red cause — all 3 failing checks shared one root cause, none of them in this PR's code. cross-target-check (x86_64-unknown-linux-musl), cross-target-check (aarch64-unknown-linux-ohos) and cross-target-smoke (x86_64-unknown-linux-musl) all died at the same point, before any niubash crate was checked:

error: use of deprecated type alias `libc::time_t`: This type is changed to 64-bit in musl 1.2.0 ...
  --> rubash/src/builtins/printf/zone.rs:367:32
error: could not compile `rubash` (lib) due to 1 previous error

Classification: upstream dependency compile error, not a product regression and not a lane-environment issue. The cross-target lanes clone rubash HEAD fresh each run (git clone --depth 1 https://github.com/unixwin/rubash.git ../rubash under the [patch] path override), and setup-rust-toolchain@v1 compiles with RUSTFLAGS=-D warnings, so the deprecation landed as a hard error on the two musl-based targets (ohos is musl too; android/bionic and the glibc hosts never see it). The Oct 17 run simply caught rubash before its fix; rubash origin master already carries 8d8537c6 fix(printf): allow the musl/ohos libc::time_t deprecation so cross-target checks stop failing (#782) with an #[allow(deprecated)] on system_local_time, and rubash's own CI is green.

Fix: no source change was needed in this branch. Rebased onto current master (d60276e, no conflicts) so the next CI run clones the fixed rubash HEAD; locally on the rebased tree: cargo fmt --check --all clean, the winuxcmd niubash-runtime tests all pass, and the Oct 17 run had already proven this commit's changes compile clean with -D warnings on glibc hosts and both android targets. Watching the new run for the musl/ohos lanes to confirm.

… contract

rubash#759 item 4 removed the zsh setopt/unsetopt aliases (rubash master
c6f4a9b3, docs/builtins.md now lists 62 builtins), so the CI lane that
clones rubash HEAD failed rubash_setopt_is_visible_when_sourcing_startup_rc
with 'setopt: command not found' (exit 127). The pinned contract itself --
option builtins are visible while the startup rc is sourced and their state
survives into the live shell -- is unchanged; re-point it at the bash-aligned
shopt builtin: -s batch form, -u, and the bare state listing, with
extglob/expand_aliases proving an actual off->on transition and dotglob
covering the set-then-unset path.
The completion builtin inventory is delegated live from
Executor::builtin_command_names(), which no longer carries setopt/unsetopt,
so test_get_builtin_commands failed on 'assertion failed:
commands.contains("setopt")' as soon as CI cloned rubash master c6f4a9b3.
Pin the new shape: shopt present, the zsh aliases absent. The empty-Tab
suggestion lists keep suggesting a name that cannot resolve otherwise, so
they swap setopt -> shopt and drop unsetopt for the same reason.

Same root as the host-contract setopt rewrite: rubash#759 item 4 removed
the zsh-compatible aliases from the engine's public builtin surface.
@caomengxuan666
caomengxuan666 merged commit 0abb0a1 into master Oct 18, 2026
9 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/activation-identity-check branch October 18, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant