Repository navigation
fix: readlink -f POSIX separators, unprivileged ln -s (+opt-in copy fallback), wpm --force shims.map refresh (Fixes #1491 #1492 #1497) - #1499
Merged
Conversation
Member
Author
|
i18n-drift fail is not from this PR. Evidence: |
caomengxuan666
force-pushed
the
fix/1491-1492-readlink-ln-wpm-force
branch
from
November 1, 2026 17:24
1dbea35 to
a12ee39
Compare
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
force-pushed
the
fix/1491-1492-readlink-ln-wpm-force
branch
from
November 1, 2026 17:59
a12ee39 to
999dceb
Compare
caomengxuan666
marked this pull request as ready for review
November 2, 2026 00:30
This was referenced Nov 2, 2026
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.
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
readlink -f/-e/-mnow print/-separated canonical names (GNUreadlink.c9.4 prints thecanonicalize_filename_mode()result verbatim, andlib/canonicalize.cassembles it with/by construction; WSL coreutils 9.4 probe:-f d/f.txt→/tmp/.../d/f.txt, zero backslashes). The drive spelling the resolver chose is kept; the no-mode form (readlink link) still prints the stored target text verbatim. This unblocks bats-core'sBATS_ROOT=$(cd -P -- "${BATS_PATH%/*/*}" && pwd -P)arithmetic.symlink()reportsfailed to create symbolic link ...and exits 1,ln.c9.4), so a silent copy can NOT be the default under the GNU-fidelity principle. The correct Windows solution comes first:CreateSymbolicLinkWis now tried withSYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE, so a Developer Mode user gets a real symlink without elevation (retry without the flag covers pre-14972 Windows and elevated tokens). On top of that,WINUX_LN_FALLBACK=copyopts into an MSYS-style copy downgrade for regular files on no-privilege hosts — silent, like MSYS, because bats-core merges stderr into its byte-exact TAP assertions (a stderr notice shiftedlines[]and broke 83 assertions in the smoke). Dangling/directory sources keep the GNU-style refusal.create_package_shimsno longer skips theshims.mapupdate when the shim link is already current: the update is hoisted into a per-command helper that runs for both theunchangedand freshly-linked paths, soinstall --forceafter an indexfilesmove (wpm-source#108 shape) heals the map without uninstall/reinstall.Verification
baseline(full differential corpus + gate),compare,oracle,baseline-growth,i18n-drift, and all fourbuild-windowsmatrix jobs (x64/arm64 × default/full editions).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).GNU_BIN=/usr/bin): newregressions/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.readlink -f→D:/repo/...for both\and/operands;ln -sdefault →ln: failed to create symbolic link 'x': Operation not permittedrc 1 (GNU-identical);WINUX_LN_FALLBACK=copy→ silent copy, rc 0, content equal.D:\repo\pre15-bats, real MSYS bash drivingbin/batswith the builtreadlink.exe/ln.exeshadowing PATH; Git Bash used only as the script host, never as an oracle):bin/bats: line 87: cd: D:\repo\pre15-bats\bin\bats: Not a directory— instant death (t5 signature, 0/199).bin/bats --version→Bats 1.14.0;mini.bats→ok/not ok/ok(3/3 executed). Negative control (env unset) still reproduces the exact t5ln: failed to create symbolic link … Operation not permitted/Executed 0 instead of expected N.bats.bats run.bats common.bats load.bats) withWINUX_LN_FALLBACK=copy: 197/199. The 2 residuals are hermetic nested-bats tests that scrub the environment (env -at bats.bats:449,env -iat 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
<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 interminfo_table.h, because in the unity build (RELEASE mode) the header is reached after an earlier command'simport 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).