Repository navigation
fix(executor): name the first failing component in simulated mkdir -p diagnostics - #3389
Conversation
… diagnostics
Simulated 'mkdir -p a/b' printed the whole operand ('a/b') when 'a' was a file; GNU prints the first failing component ('a'). Root cause: the -p branch called node.create_dir_all() (Plain: std::fs::create_dir_all; At: a hand-rolled mkdirat walk), which returns a bare io::Error with no failing component, so the diagnostic could only print the operand. The fix replaces the -p branch with mkdir_create_parents, a per-component walk structured like GNU coreutils make_ancestors: each textual prefix is created with the same root resolution as the whole operand (shell_path_to_windows -> session_path -> cp_operand_root, still the unixwin#3276 cwd-anchor route in a deleted cwd), one single create_dir per prefix (mkdirat on the At arm, fs::create_dir on Plain); after EEXIST a follow-stat decides: directory -> continue, non-directory -> ENOTDIR, stat failure (dangling symlink) -> keep the original EEXIST. Failures return (io::Error, the prefix's original spelling), and the diagnostic prints that prefix. mkdir_parent_prefixes slices the operand's original text on '/' (a/b -> ['a','a/b'], a/./b -> ['a','a/.','a/./b'], a//b -> ['a','a//b']), keeping literal separators; cuts land on '/' bytes so there is no UTF-8 split issue. The single-dir branch is untouched (still names the operand), plus a same-family empty-operand guard: 'mkdir ""' used to answer EEXIST against the session cwd, now GNU's ENOENT (mkdir -p '' went from rc 0 to ENOENT). CpNode::create_dir_all is untouched (cp -r still uses it). A survey of cp/mv/rm found no same disease: their simulated diagnostics already name the actually-failing path, and only mkdir -p does a per-component walk.
Refs unixwin#3333
Regression pin tests/issue3333_mkdir_p_failing_component_name.rs (18 tests; fail-first 6 passed / 12 failed on the unpatched tree, 18/18 pass after; supervisor verified both rounds with the patch method). Expectations are from GNU coreutils 9.4 /usr/bin/mkdir measurements (16 probed shapes; the spec is coreutils mkdir.c make_ancestors, not in the bash submodule). Adjacent: issue3276 19/19, issue1372 1/1, issue555 11/11, issue3268_cp 10/10, issue615 4/4 (supervisor re-ran issue3276 and issue555). cargo fmt clean. Also updated one comment in tests/issue3276_simulated_tools_dead_cwd.rs whose 'mkdir -p prints the operand in rubash' example no longer holds after this fix.
|
Thanks for the PR. This is queued for captain review — collaborator PRs are reviewed by the captain before merge, and #3333 stays open until that review lands. CI at intake: not green — 2 Windows legs fail, and the failure is in this PR's new code. Both failing legs report the same |
|
2026-11-12 用户令:不等作者修 Windows 面,队长接手。E0433(共享代码 libc::ENOENT/ENOTDIR 无无条件导入)由队长车道按仓内先例修(可移植判定口径),windows-gnu check 验过后回队长复核队列走完整复核。作者原提交全部保留。 |
…n shared code) The unixwin#3333 change built its fabricated ENOENT/ENOTDIR errors with io::Error::from_raw_os_error(libc::ENOENT / libc::ENOTDIR) in shared code, but external_file_builtins.rs has no unconditional libc import — every other libc:: use in the file sits inside #[cfg(unix)] items — so both Windows CI legs failed with E0433 (cannot find crate libc). Construct the three errors the crate's established portable way, io::Error::new(kind, GNU strerror text), as in command_input_scope.rs and shell_options.rs: kind() is unchanged (NotFound / NotADirectory — the kinds std maps errno 2 / 20 to), and posix_errors::message renders byte-identical text, since the raw-code table's strings for those codes and the literal payloads agree. No cfg fallback constants. Captain takeover commit on the author's branch (2026-11-12 order); the author's commits are untouched.
|
Captain review of head What passed (captain re-ran all of it on the box)
The blocker — goldens leg is red on this head, in your mechanism
The truncated prefix name can only come from the new walk. Mechanism: Required rework (one commit on this branch) In
The 18 pin expectations must not change — on Unix the new rule is cell-for-cell equivalent to the old one (an existing directory always answers Two non-blocking notes
The takeover commit stays as-is; the rework goes on top of it. #3333 stays open until the reworked head clears the goldens gate. |
… only EEXIST Captain rework on the author's branch (captain review of PR unixwin#3389, section 7.1), folding the head-CI goldens failure into this PR. The -p component walk treated only EEXIST as "possibly already exists", but on the simulated (Windows) face a bare create of an already-existing component — a drive root such as `/c` above all — can answer EACCES instead, so `mkdir -p` aborted with `mkdir: cannot create directory '/c': Permission denied` where GNU -p succeeds silently. That is the CI goldens failure in `golden_nvm_load` (nvm's load path mkdir -p's a drive-rooted operand). The walk now follow-stats the prefix after any create failure, not just EEXIST: a directory continues the walk, a non-directory is ENOTDIR naming the prefix, and a stat failure returns the original create error (a dangling symlink keeps GNU's EEXIST; a genuine failure keeps its own errno). No operand-text special cases; the decision sits at the walk's single point. On unix an existing component always answers EEXIST, so the widened trigger is observably identical there and no unix expectation changes: pin issue3333 stays 18/18 and issue3276 stays 19/19. The Windows shape has no unix-constructible form (the kernel answers EEXIST first); its regression lock is the goldens `golden_nvm_load` cell itself, named here per the review's rework terms.
…alk (#3426) fix(executor): classify emulated cp operand stat errors by the path walk Fixes #3416 ## What The emulated `cp`'s operand gates collapsed every stat failure into a hardcoded ENOENT text: the source gate tested the boolean `CpNode::exists()` and the multi-source target gate did the same. A path spelled **through a regular file** (`cp -r a/b dest` with `a` a plain file) dies its walk at the non-directory component, and GNU coreutils reports that walk's ENOTDIR — the name and exit status were already right, only the errno class in the message was wrong: - GNU: `cp: cannot stat 'a/b': Not a directory` - base: `cp: cannot stat 'a/b': No such file or directory` ## Mechanism `CpNode` gains `stat_classified()`: it keeps `stat()`'s own error and re-derives the walk verdict for a bare `NotFound` — the shape where the class is genuinely lost (the Windows face answers `ERROR_PATH_NOT_FOUND` for both a missing component and a through-file walk; unix kernels report ENOTDIR natively, which std carries as `ErrorKind::NotADirectory`). The re-derivation walks the node's proper ancestors deepest-first (plain paths via `fs::metadata`, anchor roots via cumulative-prefix `fstatat`): the first ancestor that stats as a **non-directory** is where the walk died (ENOTDIR, synthesized in the portable `ErrorKind` form); an existing **directory** ancestor means the missing component is genuinely absent and the raw ENOENT stands. Both `cp` operand gates (source `cannot stat` and multi-source `target`) now print the classified error through `posix_errors::message`, the same rendering the family's other tools (rm/touch/cat) already used — which is why they measured SAME in the probe round and this one did not. ## 本 PR 删除了什么 Nothing — no code or tests removed; two hardcoded diagnostic strings are replaced by the classified rendering and the `exists()` gates by stat gates at the same two sites. ## Evidence Three-way probe (GNU coreutils 9.4 / base `f6e8c674` / this head), 22 shapes over the whole emulated file-builtin family — the through-file shapes flip to GNU-identical, every conservation shape is byte-identical before and after: `cp` plain/`-r`/deep/target (ENOTDIR), plain-missing stays ENOENT, `rm`/`rm -f`/`touch`/`cat` unchanged, `mv`/`ln`/`install`/`stat` are not rubash-emulated (real binaries; SAME by construction). Regression pin `tests/issue3416_cp_stat_classification.rs` (5 tests): the two through-file tests fail on base, all five pass on head; neighbour pin issue3276 stays 19/19; lib failure name-set empty. One measured sibling is deliberately NOT folded into this PR: the same probe round found the emulated `chmod`'s apply arm discards its metadata error the same way (`chmod 600 a/b` prints the ENOENT text on base and on this head). chmod does not consume `CpNode` — it is a separate call chain with its own mode-store semantics — so it is filed as #3425 with the full probe evidence for its own lane, rather than widening this PR's surface. ## Verification (captain review) - Captain verdict PASS (`~/workspace/review-3426/CAPTAIN-VERIFY.md`): probe table and both pin binaries independently re-executed by the captain (cp face diff vs GNU = ∅ at head; pins 5/5 and 19/19); lane primary logs read directly (base top-up fail-first = exactly the two through-file names; lib 1246/0; full-target `-D warnings` forced recheck 1505 flagged invocations, 0 errors; fmt/marker-literal/UTF-8 hygiene rc=0). Old-server legs were displaced by the server's sshd banner outage during the review window; the finished CI on this head is fully green including GNU goldens, both cross-target checks, macOS and Windows compile legs. - Merge obligation carried from the lane report: whichever of this PR and PR #3389 (same file, textually non-overlapping regions) lands second, its merged head must run issue3333 (18/18) + issue3416 (5/5) together.
Fixes #3333
What was fixed
Simulated
mkdir -p a/bprinted the whole operand ('a/b') whenawas a file; GNU prints the first failing component ('a').Root cause: the
-pbranch callednode.create_dir_all()(Plain arm:std::fs::create_dir_all; At arm: a hand-rolled mkdirat walk), which returns a bareio::Errorwith no failing component, so the diagnostic could only print the operand. The fix replaces the-pbranch withmkdir_create_parents, a per-component walk structured like GNU coreutilsmake_ancestors: each textual prefix is created with the same root resolution as the whole operand (shell_path_to_windows→session_path→cp_operand_root, still the #3276 cwd-anchor route in a deleted cwd), one singlecreate_dirper prefix (mkdirat on the At arm,fs::create_diron Plain); after EEXIST a follow-stat decides — directory → continue, non-directory → ENOTDIR, stat failure (dangling symlink) → keep the original EEXIST. Failures return(io::Error, the prefix's original spelling), and the diagnostic prints that prefix.mkdir_parent_prefixesslices the operand's original text on/(a/b→["a","a/b"],a/./b→["a","a/.","a/./b"],a//b→["a","a//b"]), keeping literal separators; cuts land on/bytes so there is no UTF-8 split issue. The single-dir branch is untouched (still names the operand), plus a same-family empty-operand guard:mkdir ""used to answer EEXIST against the session cwd, now GNU's ENOENT (mkdir -p ""went from rc 0 to ENOENT).CpNode::create_dir_allis untouched (cp -r still uses it). A survey of cp/mv/rm found no same disease: their simulated diagnostics already name the actually-failing path, and onlymkdir -pdoes a per-component walk.Specification note: this one's spec is GNU coreutils
mkdir.cmake_ancestors, not the bash submodule (which only holds bash). Expectations are from system GNU coreutils 9.4/usr/bin/mkdirmeasurements (16 probed shapes, spelling preserved verbatim:./a/b→'./a',a/./b/c→'a/./b',a//b/c→'a//b',../x/y→'../x', absolute paths, dangling-symlink components keep EEXIST, multi-operand continues after a failure with rc 1).What was deleted
Nothing. No files, features, or tests were removed. One comment in
tests/issue3276_simulated_tools_dead_cwd.rswas updated (its "mkdir -p prints the operand in rubash" example no longer holds after this fix).Verification (all run, per-item counts)
tests/issue3333_mkdir_p_failing_component_name.rs: 18/18 pass (stderr asserted word-for-word, rc and landing points asserted alongside). Fail-first on the unpatched tree (supervisor re-ran with the patch method): 6 passed / 12 failed — exactly the 12 divergence faces were red (first component, second component, deleted cwd, empty operand ×2,./,/.,//, absolute path,../, multi-operand, dangling multi-level); the 6 green cells are controls/conservation (single-dir operand name,mkdir -p .,/, success chain, symlink-to-directory, dangling single level).issue3276_simulated_tools_dead_cwd19/19,issue1372_chmod_mkdir_redirect_regressions1/1,issue555_file_builtin_family_regressions11/11,issue3268_cp_anchored_operands10/10,issue615_copy_contents4/4 (supervisor re-ran issue3276 and issue555).cargo build -j 2clean,cargo fmt --checkclean.src/lexer/continuation.rsuntouched.Owed
/; a backslash-separated operand degrades to a single prefix on Windows (same as pre-fix behavior, no regression). No Windows environment on this machine to test with.