Skip to content

fix(doctor): skip Windows-only checks on non-Windows platforms - #242

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/doctor-linux-skip
Oct 10, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/doctor-linux-skip

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #194.

What

niu doctor probed the Windows command layer (winuxcmd core, command links, bash/sh shims) on every platform. On Linux those probes can never succeed, so the report ended with a false 1/3 critical checks passed implying a broken install.

Changes (crates/niubash-runtime/src/doctor.rs)

  • New Platform enum (Windows/Unix), resolved at compile time via cfg!(windows) but branched as an injected value so the skip logic is unit-tested on any host OS.
  • Windows-only critical checks are probed only on Windows; on unix they render as n/a on this platform — Windows component, skipped info rows and are excluded from the critical tally (Linux: 1 critical check = startup rc).
  • Header now names the platform: niubash doctor — x.y.z (windows|unix).
  • Terminal row falls back to TERM on unix instead of the Windows-only WT_SESSION.
  • Bundled-tools row (interacts with setup: detect release-bundled components as present (follows #230) #231's bundled tools): on unix the winuxcmd opt/ layout does not exist, so an empty bundle reads n/a — bundled tools ship in the Windows release layout instead of implying nothing is installed; on Windows the row is unchanged.

Testing

  • Unit tests: platform gating decision, n/a row text (shared constant asserted directly), bundled-tools row per platform, distinct header labels — all pass on Windows host.
  • Windows regression: local niu doctor output unchanged (3/3 critical checks passed, same rows; header gains (windows)).
  • Linux behavior (skip rows, 1/1 tally, TERM terminal row) is verified by the CI Linux jobs — no Linux toolchain available locally.
  • 3 pre-existing plugins::distros test failures (offline git clone in sandbox) reproduce on a clean checkout of master; unrelated.

winuxcmd core, command links and bash/sh shims are the Windows command
layer; on Linux/macOS they can never be found, so doctor reported
'1/3 critical checks passed' and implied a broken install.

- gate those checks behind a Platform enum (compile-time cfg!(windows),
  injected value in tests) and report them as n/a rows outside the
  critical tally on unix
- name the platform in the header line
- terminal row falls back to TERM instead of WT_SESSION on unix
- bundled-tools row reads n/a (Windows release layout) instead of
  implying an empty install when the winuxcmd tree is absent

Linux behavior is verified by the repo CI Linux jobs; local validation
covered the unchanged Windows report (3/3 critical checks passed).
@caomengxuan666
caomengxuan666 merged commit 801b2fc into master Oct 10, 2026
3 of 9 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/doctor-linux-skip branch October 10, 2026 03:36
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.

[docs/bug] niu doctor 在 Linux 上报 winuxcmd/command links 缺失,但它仅是 Windows 组件

1 participant