Repository navigation
fix(mktemp): resolve the default dir through winux_core tmp_base — MSYS TEMP=/tmp broke -p /tmp on CI (#1767) - #1792
Merged
Conversation
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
…#1792) mk16 CI root cause (diagnostic run: created parent = runner TEMP root while TMPDIR named an existing harness dir): tmp_base discarded EVERY '/'-prefixed candidate, including the MSYS drive spelling /c/Users/... that the C++ unit harness feeds as TMPDIR. The fold chain the dialect already owns resolves that spelling natively, so the skip threw away a usable candidate and dropped mktemp onto TEMP. tmp_base now folds /cygdrive/X, /mnt/X and /X onto the drive form (normalize_api_operand_w's chain, #1145 #1172 #1231) and adopts the candidate only when the folded path names an existing directory; /tmp and /var/tmp stay unadopted because shell_tree_map maps them THROUGH tmp_base (the circular mapping the mk16-p-dir finding removed), and every other unusable value falls through to the next candidate, keeping niubash#94's usable-per-user-temp fallback. GNU anchor: coreutils 9.4 mktemp.c get_temp_dir honors TMPDIR verbatim (src/mktemp.c, set_program_name/default template path); the fold adopts exactly the spellings that name a real directory in the shell dialect, which is what the #1761 re-pin test (probe: coreutils emits '~' inside TMPDIR unchanged) already required the display side to honor. Verified: cargo test winux-core 33/33 + mktemp 8/8; driver probes (no-positional mktemp, the CI harness shape): TMPDIR=/d/repo -> created D:/repo/tmp.* (adopted), TMPDIR=/tmp -> GetTempPathW root (circular fell through). WSL GNU 9.4 oracle probe confirms an explicit-template mktemp never consults TMPDIR (bare CWD name), so the adoption changes only the implied-tmpdir path the harness uses. Also: rustfmt on fsutil.rs (repo-wide hook).
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
…tes (#1792 mirror) The #1769 skip threw away EVERY '/'-prefixed candidate — including the MSYS drive spelling /c/Users/... that names a real Windows directory through the dialect's existing folds. The rust2 twin's CI diagnostic (#1792) pinned the exact shape: TMPDIR pointed at an existing harness directory, mktemp created in the TEMP root instead. tmp_base_w now folds /cygdrive/X, /mnt/X and /X onto the drive form (the fold chain normalize_api_operand_w already owns, #1145 #1172 #1231) and adopts the candidate only when the folded path is an existing directory; /tmp and /var/tmp stay unadopted because shell_tree_map_w maps them THROUGH this function (the circular mapping #1769 removed), and every other unusable value falls through, keeping niubash#94's usable-per-user-temp fallback. The folds are forward-declared at their definition scope for the candidate loop. Verified: native_path 5/5 (3 existing pins unchanged + adopt + fall- through mirrors), winuxcmd-tests builds clean under vcvars.
…YS TEMP=/tmp broke -p /tmp on CI (#1767) mktemp.rs carried its own TMPDIR/TEMP/TMP env loop that trusted the values verbatim. Under a Git Bash parent (the CI shard env), TEMP/TMP arrive as the MSYS form '/tmp' itself: /tmp resolved circularly to /tmp, and every -p /tmp creation failed rc 1 on the runner (fs-dirs mk16-p-dir) while local runs passed (local parents keep the Windows form). winux_core path.rs tmp_base (landed with #1766) already solves this class — POSIX-spelled candidates are skipped and GetTempPathW (which skips non-existent candidates) provides the per-user temp — so mktemp now delegates to it instead of duplicating the priority loop. Verified: TEMP=/tmp TMP=/tmp driver mktemp -p /tmp mk16.XXXXXX -> creates in %LOCALAPPDATA%/Temp rc 0 (was rc 1); mktemp 8/8.
…template TMPDIR row The CI runner fails equivalent(parent, out_dir) but passes locally — and equivalent() prints neither path, leaving the mismatch undiagnosable. lexically_normal().string() comparison prints both sides on failure (and is case/slash-tolerant).
…#1792) mk16 CI root cause (diagnostic run: created parent = runner TEMP root while TMPDIR named an existing harness dir): tmp_base discarded EVERY '/'-prefixed candidate, including the MSYS drive spelling /c/Users/... that the C++ unit harness feeds as TMPDIR. The fold chain the dialect already owns resolves that spelling natively, so the skip threw away a usable candidate and dropped mktemp onto TEMP. tmp_base now folds /cygdrive/X, /mnt/X and /X onto the drive form (normalize_api_operand_w's chain, #1145 #1172 #1231) and adopts the candidate only when the folded path names an existing directory; /tmp and /var/tmp stay unadopted because shell_tree_map maps them THROUGH tmp_base (the circular mapping the mk16-p-dir finding removed), and every other unusable value falls through to the next candidate, keeping niubash#94's usable-per-user-temp fallback. GNU anchor: coreutils 9.4 mktemp.c get_temp_dir honors TMPDIR verbatim (src/mktemp.c, set_program_name/default template path); the fold adopts exactly the spellings that name a real directory in the shell dialect, which is what the #1761 re-pin test (probe: coreutils emits '~' inside TMPDIR unchanged) already required the display side to honor. Verified: cargo test winux-core 33/33 + mktemp 8/8; driver probes (no-positional mktemp, the CI harness shape): TMPDIR=/d/repo -> created D:/repo/tmp.* (adopted), TMPDIR=/tmp -> GetTempPathW root (circular fell through). WSL GNU 9.4 oracle probe confirms an explicit-template mktemp never consults TMPDIR (bare CWD name), so the adoption changes only the implied-tmpdir path the harness uses. Also: rustfmt on fsutil.rs (repo-wide hook).
caomengxuan666
force-pushed
the
fix/mktemp-default-dir-tmpbase
branch
from
November 16, 2026 04:25
6aa6175 to
79a2ccf
Compare
mk16-p-dir (fs-dirs shard, exit mode) had r_rc=1 where GNU has a real
/tmp and exits 0: shell_tree_map's install-root gate precedes the /tmp
arm, so without WINUXSH_ROOT the -p operand fell through to the generic
resolve and the spelling joined the cwd drive (C:\tmp), which the CI
runner does not have.
GNU uses the -p operand as dest_dir verbatim (src/mktemp.c:276-310) and
prints file_name_concat(dest_dir, template) (src/mktemp.c:341); the
Windows counterpart of "a real /tmp" is tmp_base (niubash#94). Extract
that mapping into winux_core::path::tmp_namespace_map — the single owner
of /tmp = tmp_base and /var/tmp = <tmp_base>/var/tmp
(native_path.cppm:257/:262) — and have both shell_tree_map (inside its
root gate, semantics unchanged) and mktemp's -p arm use it.
Review of the branch draft also fixed two defects:
* /var/tmp was mapped to tmp_base itself, not <tmp_base>/var/tmp, so
`-p /var/tmp` created in the temp root;
* display_join kept a trailing separator run (`-p D//` printed
`D//name`); GNU collapses it (probed 9.4: D/, D//, D/// all print
`D/name`).
Tests: mktemp p_dir_bare_tmp_namespace_creates_via_tmp_base (four
spellings; display prefix + on-disk location), winux-core
tmp_namespace_maps_without_a_shell_root (root-less mapping, negative
spellings, shell-tree parity). cargo test -p winux-cmds: 1018 passed;
cargo test -p winux-core: 34 passed.
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
…r mapping (Fixes #1769) (#1780) * fix(path): tmp_base_w skips POSIX-spelled TEMP/TMP — Git Bash circular mapping (#1769) Under a Git Bash parent, TEMP/TMP arrive as the MSYS form '/tmp' itself: tmp_base_w trusted the value verbatim, so /tmp resolved circularly to /tmp and every temp-file command failed (same class as the rust2 side's fix in winux-core path.rs tmp_base). Mirrors the rust2 fix: POSIX-spelled candidates (leading '/') are skipped in the TMPDIR > TEMP > TMP priority walk; when every candidate is POSIX-spelled, GetTempPathW provides the Windows default per-user temp (it skips candidates that do not exist, landing on USERPROFILE). Purity note documented: the last-resort arm reads process state on purpose. Tests: native_path_unit_test +3 (MSYS-form env resolves to the real per-user temp; native-form candidates unaffected; GetTempPathW arm covered via the /tmp fold path). Verified: VS build green; native_path.* 3/3; related group 103/103; Git Bash-parent repro (TEMP=/tmp mktemp -p /tmp) rc 0 — was failure; full suite 4034/4040 (6 pre-existing env items, unrelated). * fix(native_path): resolve-then-adopt POSIX-spelled tmp_base_w candidates (#1792 mirror) The #1769 skip threw away EVERY '/'-prefixed candidate — including the MSYS drive spelling /c/Users/... that names a real Windows directory through the dialect's existing folds. The rust2 twin's CI diagnostic (#1792) pinned the exact shape: TMPDIR pointed at an existing harness directory, mktemp created in the TEMP root instead. tmp_base_w now folds /cygdrive/X, /mnt/X and /X onto the drive form (the fold chain normalize_api_operand_w already owns, #1145 #1172 #1231) and adopts the candidate only when the folded path is an existing directory; /tmp and /var/tmp stay unadopted because shell_tree_map_w maps them THROUGH this function (the circular mapping #1769 removed), and every other unusable value falls through, keeping niubash#94's usable-per-user-temp fallback. The folds are forward-declared at their definition scope for the candidate loop. Verified: native_path 5/5 (3 existing pins unchanged + adopt + fall- through mirrors), winuxcmd-tests builds clean under vcvars.
This was referenced Nov 16, 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.
Standalone extraction of the mk16 fix (also carried in the mv reland lineage).
mktemp.rs carried its own TMPDIR/TEMP/TMP env loop that trusted the values verbatim. Under a Git Bash parent (the CI shard env), TEMP/TMP arrive as the MSYS form '/tmp' itself: /tmp resolved circularly to /tmp, and every -p /tmp creation failed rc 1 on the runner (fs-dirs mk16-p-dir) while local runs passed (local parents keep the Windows form).
winux_core path.rs tmp_base (landed with #1766) already solves this class — POSIX-spelled candidates are skipped and GetTempPathW (which skips non-existent candidates) provides the per-user temp — so mktemp now delegates to it instead of duplicating the priority loop.
Verified on the fresh main build: TEMP=/tmp TMP=/tmp driver mktemp -p /tmp mk16.XXXXXX -> creates in %LOCALAPPDATA%/Temp rc 0 (was rc 1); mktemp 8/8; build clean.