Skip to content

fix: readlink -f POSIX separators, unprivileged ln -s (+opt-in copy fallback), wpm --force shims.map refresh (Fixes #1491 #1492 #1497) - #1499

Merged
caomengxuan666 merged 5 commits into
mainfrom
fix/1491-1492-readlink-ln-wpm-force
Nov 2, 2026
Merged

caomengxuan666 merged 5 commits into
mainfrom
fix/1491-1492-readlink-ln-wpm-force

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

WIP: 1.2.1 candidate — fixes the two #1491 tool gaps that block bats-core and the #1492 wpm shims.map staleness. Refs #1491, Refs #1492. Draft until 1.2.0 ships; do not merge before the release. Rebased onto main @62c9cdbe (1.2.0 packaging + the #1486/#1494 baseline adjudication).

Per-issue summary

Verification

  • CI on this head: all green — baseline (full differential corpus + gate), compare, oracle, baseline-growth, i18n-drift, and all four build-windows matrix jobs (x64/arm64 × default/full editions).
  • Unit tests: ctest -L WinuxCmd -R '^(readlink|ln|wpm)\.' → 129/129 PASS (8 new: 3 readlink separator/bats-arithmetic, 4 ln fallback branches, 1 wpm force-reconcile; ln tests adapt to whether the session can create real symlinks).
  • Differential (WSL GNU coreutils 9.4 oracle, GNU_BIN=/usr/bin): new regressions/121-readlink-f-posix-separators.case + 122-…-m-missing… PASS with the fix and record OUT_DIFF against the installed 1.1.20 binary (they discriminate). Existing readlink/ln corpus buckets unchanged. Baseline ledger 642 → 644 (+2 PASS, on top of the fix(differential): adjudicate the 23 gate-blocking cases (#1486 baseline half) #1494 adjudication), growth gate OK.
  • Probes: readlink -f → D:/repo/... for both \ and / operands; ln -s default → ln: failed to create symbolic link 'x': Operation not permitted rc 1 (GNU-identical); WINUX_LN_FALLBACK=copy → silent copy, rc 0, content equal.
  • bats-core E2E (D:\repo\pre15-bats, real MSYS bash driving bin/bats with the built readlink.exe/ln.exe shadowing PATH; Git Bash used only as the script host, never as an oracle):
    • Before: bin/bats: line 87: cd: D:\repo\pre15-bats\bin\bats: Not a directory — instant death (t5 signature, 0/199).
    • After: bin/bats --version → Bats 1.14.0; mini.bats → ok/not ok/ok (3/3 executed). Negative control (env unset) still reproduces the exact t5 ln: failed to create symbolic link … Operation not permitted / Executed 0 instead of expected N.
    • t5 subset (bats.bats run.bats common.bats load.bats) with WINUX_LN_FALLBACK=copy: 197/199. The 2 residuals are hermetic nested-bats tests that scrub the environment (env - at bats.bats:449, env -i at bats.bats:1373), so the opt-in cannot reach them; both pass on hosts where symlinks are creatable (Developer Mode / elevation), which is the path change 1 makes the default.

Notes for reviewers

  • The first commit restores <ctime>/<string_view> direct includes: the 14.51.36231 MSVC (local VS 18 Community and the CI windows-2025 image) no longer delivers them transitively through the pch.h chain, so a clean checkout of pre-1.2.0 main stopped compiling locally. <string_view> lives in the PCH, not in terminfo_table.h, because in the unity build (RELEASE mode) the header is reached after an earlier command's import std; and a real std header past an import is a redefinition error (first CI round failed exactly there; both flavors verified since: DEV non-unity and RELEASE unity with CI's flags).
  • No i18n catalog sync needed: the copy downgrade is silent by design, so no new user-visible message was added.
  • Scope boundary: [ecosystem] nvm/bats 被 3 个工具 gap 挡住:awk 管道 CRLF / readlink -f 反斜杠 / ln -s 无降级(发版前 T5,1.2.1 候选) #1491's awk-CRLF item (W2) is not touched here; bats residuals beyond the two hermetic-env tests may need it.

@caomengxuan666

Copy link
Copy Markdown
Member Author

i18n-drift fail is not from this PR. Evidence: check_i18n_drift.py against current i18n-repo main reports the same 26 entries (kill-option + legacy keys) on clean origin/main (ff5aa890) as on this branch — this PR adds zero drift (the ln copy downgrade is silent, no new user-visible message). Root cause: unixwin/winuxcmd-i18n@f4d5da1 (W8 kill sync, 2026-11-01 23:29 +0800) landed after main's last green CI run (13:43Z) and syncs kill to the procps surface rewrite WinuxCmd source state, whose companion PR is not in main yet. Any PR (or a plain re-run of main) fails this check until the kill companion lands. baseline-growth is green; watching the remaining checks.

@caomengxuan666
caomengxuan666 force-pushed the fix/1491-1492-readlink-ln-wpm-force branch from 1dbea35 to a12ee39 Compare November 1, 2026 17:24
@caomengxuan666 caomengxuan666 reopened this Nov 1, 2026
The 14.51.36231 MSVC (local VS 18 Community and the CI windows-2025
image alike) no longer reaches <time.h> and <string_view> transitively
through the pch.h include chain, so cpio/pinky/logger (localtime_s,
strftime) and the shared terminfo table (std::string_view in
find_term/lookup_term) stop compiling on a clean checkout of main.

<string_view> goes into the PCH, not into terminfo_table.h: in the
unity build (BUILD_MODE=RELEASE) the header is reached AFTER an earlier
command's 'import std;', and a real std header included past an import
is a redefinition error (unity TU failed C2953/C2995 on
iosfwd/__msvc_string_view.hpp). The PCH include path runs before every
import. Verified in both flavors: DEV (non-unity, tests) and RELEASE
(unity, CI flags -DBUILD_MODE=RELEASE -DENABLE_TESTS=OFF
-DCMAKE_CXX_MODULE_STD=ON).

Also ignore target/ (local agent scratch: build logs, probes).
GNU readlink prints the canonicalize_filename_mode() result verbatim
(readlink.c, 9.4: fputs(value, stdout)), and that canonical name is
assembled with '/' separators by construction (lib/canonicalize.c, 9.4:
'if (!ISSLASH (dest[-1])) *dest++ = "/";'). WSL coreutils 9.4 probe:
'readlink -f d/f.txt' -> '/tmp/.../d/f.txt', zero backslashes; the raw
link text from 'readlink link' prints verbatim.

WinuxCmd printed the resolver's native spelling (backslashes), which the
shell's pattern word arithmetic cannot consume: bats-core computes
BATS_ROOT with ${BATS_PATH%/*/*} and died at bin/bats:87
('cd: D:\repo\pre15-bats\bin\bats: Not a directory', 0/199 tests).

The -f/-e/-m modes now render the resolved name in the repo's
shell-facing display form ('/' separators, like find.cpp's path_to_utf8);
the drive spelling the resolver chose is kept, and the no-mode form still
prints the stored target text verbatim.

Differential regressions 121/122 pin the invariant against the WSL 9.4
oracle through a tr filter that deletes every legal path character
except a backslash; both sides print nothing. They record OUT_DIFF
against WinuxCmd 1.1.20. Baseline: 518 -> 520 cases (+2 PASS).
…rade (Refs #1491)

GNU ln has no fallback: a failed symlink() is reported through the
'failed to create symbolic link %s -> %s' path (ln.c, 9.4) and ln exits
1. That stays the default, so GNU fidelity is preserved.

Two changes for hosts without SeCreateSymbolicLinkPrivilege:

1. Try SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE first: with Windows
   Developer Mode enabled an unprivileged user gets a REAL symlink. On
   Windows that predates the flag the call fails
   ERROR_INVALID_PARAMETER and a retry without it restores the old
   behaviour; an elevated token passes either way.

2. WINUX_LN_FALLBACK=copy opts into an MSYS-style downgrade: when the
   privilege-class failure hits and the source is an existing regular
   file, copy it (bats-core's bats_create_file_tempdirs ln -s runs under
   set -e and killed every suite with 0 executed before this). Like the
   MSYS downgrade it mirrors, the copy is SILENT: bats merges stderr
   into its TAP stream and asserts it byte-exact. Dangling and
   directory sources keep the GNU-style refusal - a copy cannot
   represent them.

Unit tests cover all four branches mode-adaptively (the suite probes
whether the session can create real symlinks).
… (Refs #1492)

create_package_shims skipped the shims.map update whenever a package's
shim already existed and already linked the forwarder (the 'unchanged'
continue), so a --force reinstall whose index mapping moved the payload
left the map pointing at the old location and the forwarder answered
'winuxcmd-shim: the payload for \'<cmd>\' is missing' (exit 127).
uninstall + install was the only recovery.

Hoist the map update into a per-command record_shim_payload lambda that
runs for BOTH the unchanged and the freshly-linked paths; the payload
resolution in shim_payload_for already handles both.

Regression: install (payload opt\tool\tool.exe) -> index moves the
mapping to bin/tool.exe -> --force -> map must say
opt\tool\bin\tool.exe while the shim link never changed.
@caomengxuan666
caomengxuan666 force-pushed the fix/1491-1492-readlink-ln-wpm-force branch from a12ee39 to 999dceb Compare November 1, 2026 17:59
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 2, 2026 00:30
@caomengxuan666 caomengxuan666 changed the title WIP: fix readlink -f separators, unprivileged ln -s, wpm --force shims.map (1.2.1; Refs #1491, Refs #1492) fix: readlink -f POSIX separators, unprivileged ln -s (+opt-in copy fallback), wpm --force shims.map refresh (Fixes #1491 #1492 #1497) Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compat-gap 与 GNU 行为不一致,已复现待修

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant