Skip to content

fix(vfs): keep VFS paths slash-separated on Windows - #2936

Merged
chaliy merged 2 commits into
mainfrom
claude/project-thread-sx9opx
Nov 18, 2026
Merged

chaliy merged 2 commits into
mainfrom
claude/project-thread-sx9opx

Conversation

@chaliy

@chaliy chaliy commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

  • On Windows, redirects to /dev/stdout, /dev/stderr, /dev/stdin and /dev/fd/N are handled by the interpreter again, as on Linux, instead of being written to the VFS as regular files (closes Windows: redirect to /dev/stdout or /dev/stderr goes to the file system #2933).
  • Same bug class, fixed at the other sites: mkdir -p parent checks in PosixFs, cd x/.., readlink -f prefix probes, OverlayFs upper-dir counting, and git refs/heads/<name> paths. Custom FileSystem/FsBackend implementations on Windows no longer receive \-joined paths like /a\b.
  • Static guard: crates/bashkit/clippy.toml bans Path::join, PathBuf::push, PathBuf::set_file_name and Path::with_file_name in the bashkit crate. Host-path code (RealFs, host mounts, test/bench/example temp paths) opts out with a scoped #[allow] and a reason.
  • bashkit::testing::CheckedFs: a FileSystem wrapper that records every path received and flags \. New vfs_separator_tests run device redirects, mkdir -p, cd .. and readlink -f through it.
  • Windows CI (test-windows) now also runs the integration windows_containment, dev_fd_path_tests and dev_null_tests filters; new lib tests named windows_containment_* are picked up by the existing windows-containment job.
  • custom_backend and custom_filesystem_impl examples no longer teach the PathBuf::push normalizer; they call bashkit::normalize_path/vfs_join.

Why

normalize_dev_path rebuilt the already-clean path with PathBuf::push, which joins with the host separator, so on Windows /dev\stderr missed the string match. This is the second sweep of this class after #2425. Fuzzing and Linux CI cannot see it because the Linux separator already is /, so the fix adds a compile-time ban instead of relying on another sweep. A trial run of the ban is what found the other sites.

Before / After

Before (Windows): echo hi > /dev/stderr → empty stderr, VFS file /dev/stderr created; a string-keyed custom backend sees stat("/a\b") during mkdir -p /a/b/c.
After: output lands on stderr, no VFS write. CheckedFs and the backend recorder see only /-joined paths. Linux behavior is unchanged.

Local (Linux): just pre-pr green (fmt, clippy --all-targets --all-features -D warnings with the new ban, tests, vet). cargo test -p bashkit --lib -- windows_containment 12 pass, --test integration -- windows_containment dev_fd_path_tests dev_null_tests 51 pass. The Windows-specific failure mode is only exercisable on the Windows runner.

Risk

  • Low. Only path construction changes; every changed site already fed paths that the built-in backends normalize. The clippy ban may need #[allow] on future legitimate host-path code.

Checklist

  • Tests added or updated
  • Backward compatibility considered

🤖 Generated with Claude Code

On Windows, `echo x > /dev/stderr` wrote a VFS file: dev_fd_alias
re-normalized the target with PathBuf::push, producing /dev\stderr, which
missed the device match (#2933). Use the shared normalize_path.

A clippy run with host-separator joins banned found the rest of the class:
PosixFs mkdir -p parent checks (backend saw /a\b), cd x/.., readlink -f
prefix probes, OverlayFs upper-dir counting, and git refs/heads paths.
All now use vfs_join.

Guard against a third sweep: crates/bashkit/clippy.toml bans Path::join,
PathBuf::push, set_file_name and with_file_name, with scoped allows for
host-path code. testing::CheckedFs records the paths a filesystem receives;
Windows CI now runs the device-path and separator integration tests.
Public custom-fs examples no longer teach the push pattern.

Closes #2933
@chaliy chaliy self-assigned this Nov 18, 2026
The new Windows CI step runs dev_fd_path_tests; on windows-latest `bash` is
the WSL launcher, which prints a UTF-16 notice instead of running the script.
Bashkit's own output assertions still run on every host.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 6813cf2 Commit Preview URL

Branch Preview URL
Nov 18 2026, 06:07 PM

@chaliy
chaliy merged commit 7c0ce82 into main Nov 18, 2026
67 checks passed
@chaliy
chaliy deleted the claude/project-thread-sx9opx branch November 18, 2026 18:44
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.

Windows: redirect to /dev/stdout or /dev/stderr goes to the file system

1 participant