Skip to content

fix(wsl): read a UNC drive-mount project's files through its drive path - #33735

Merged
nwparker merged 3 commits into
mainfrom
nwparker/wsl-unc-drive-fs-reads
Oct 26, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/wsl-unc-drive-fs-reads

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​313 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​313
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​66

ELI5

On Windows, a project can be opened through WSL's network path to a Windows drive, for example \\wsl.localhost\Ubuntu\mnt\c\src\app. Newer WSL releases refuse Windows programs that open files that way, although the very same folder opens fine as C:\src\app. Orca now reads such a project's files through the C:\ path, while still showing and storing the path the user chose.

What Changed

Before, on WSL 2.7 and later, for a project saved under \\wsl.localhost\<distro>\mnt\<drive>\...:

  • The file explorer stayed empty. Listing a folder failed with EPERM: operation not permitted, realpath '\\wsl.localhost\...'.
  • Every project open logged an EPERM warning for each setup-script import file Orca checks (package.json, conductor.json, .cmux/cmux.json, …), and no import was offered.

After:

  • The file explorer lists the folder.
  • Setup-script imports are found.
  • No EPERM warnings.
  • Paths the user sees and saved ids keep the UNC spelling.

Mechanism (new src/main/wsl/wsl-unc-drive-fs-path.ts):

  • wslUncDriveFsPath maps a UNC path into a distro's drive mount (/mnt/<letter>) to the drive path, on Windows only. Folders inside the distro (\home), other network shares and non-Windows hosts are left alone.
  • File-access authorization (filesystem-auth.ts, normalizeExistingPath) resolves such a path's real path through the drive, then turns the answer back into the caller's UNC spelling. The allow-list check is therefore unchanged: a path is still allowed only if it sits under an allowed UNC root, so access is not widened.
  • fs:readDir (and its symlink classification), the setup-script import candidate reads and the orca.yaml checks (hasHooksFile, loadHooks, the unknown-key probe) hand the drive path to the filesystem. Before, a saved /mnt/c project's setup hooks silently disappeared.
  • Authorization is unchanged. A UNC drive-mount path is still judged against the UNC allow-list roots: the real path found through the drive is turned back into UNC before the check. A junction or symlink under the project whose real path lands on another drive (D:\… becomes \\wsl.localhost\<d>\mnt\d\…) or anywhere outside the project is therefore still refused. A test pins this.

Why

  • WSL's file server refuses drive-mount paths over UNC, so no retry or permission change on the UNC path can help. The drive path is the same folder on the same disk.
  • Mapping only at the point where the filesystem is called keeps everything that compares or stores paths (worktree ids, allow-list roots, what the renderer shows) in the spelling it already uses. Re-saving projects under C:\ would change their identity; that is a separate, opt-in conversion.
  • This pairs with fix(wsl): keep a UNC drive-folder project's worktrees under their saved names #33706, which stops worktree discovery from re-spelling these projects as C:\.

Linked Issue

Internal WSL rework; found by a real-host test on WSL 2.7.11.

Visual Proof

N/A: the change is in main-process file reads. Before, the file explorer was empty and the log showed EPERM; the evidence is from the real-host run described above.

Testing

  • New tests:

    • src/main/wsl/wsl-unc-drive-fs-path.test.ts: the mapping; that \home, shares and non-Windows are untouched; and real-path resolution when every UNC access throws EPERM.
    • src/main/ipc/hooks/worktree-hook-inspection-unc-drive.test.ts: the import candidate is found through C:\, with no EPERM warning. Without the fix it fails.
    • src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts: fs:readDir with every UNC access throwing EPERM, plus junctions to D:\ and to a folder outside the project being refused. It needs native Windows path resolution, so the suite is gated on win32 and registered in the Windows package lane (package (windows) → "Test Windows-specific boundaries").
  • src/main/hooks-orca-yaml-unc-drive.test.ts: orca.yaml is found and parsed through C:\ when UNC access throws EPERM. It fails without the fix.

  • Checks run:

    • pnpm tc passes.
    • Nearby suites (filesystem, hooks, wsl, providers, runtime files, media) pass.
    • The changed-code quality gate and lint ratchets pass. The full pnpm lint stops only at a localization-coverage finding in settings files on main that this PR does not touch.
  • Tested on macOS (unit). The Windows-only suite runs in the Windows package lane.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Windows only: other platforms take no new path.
  • SSH: SSH repos never reach these local reads.
  • Folder workspaces go through the same authorization.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

WSL 2.7 refuses Windows file access to its drive mounts over UNC: \\wsl.localhost\<distro>\mnt\c\x
answers EPERM, while the distro's own folders still open. A project saved under such a path lost
its file explorer (fs:readDir failed on the authorization realpath) and logged an EPERM warning
for every setup-script import candidate.

The authorization realpath now resolves a UNC drive-mount path through its drive and answers in
the caller's UNC spelling, so allow-list checks are unchanged; readdir and the import-candidate
reads open the same folder by drive path. Distro folders, other UNC shares and non-Windows hosts
are untouched.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76171d75-4332-4fed-aa16-278cd82642fa
Commits

Reviewing files that changed from the base of the PR and between 9b135d6 and f46a0d6.

Files selected for processing: 4
  • config/scripts/pr-package-test-paths.mjs
  • src/main/hooks-orca-yaml-unc-drive.test.ts
  • src/main/hooks.ts
  • src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The change adds helpers that convert recognized WSL UNC paths to Windows drive paths and resolve real paths across those mounts. Filesystem authorization and path containment use the new realpath helper. Directory reads, symlink checks, setup-script inspection, and Orca YAML operations convert paths before filesystem access. New tests cover path conversion, realpath results, and UNC-backed operations.

Priority: Normal

Merge Risk: Moderate · up to f46a0

Some file operations in WSL-mounted projects may still fail despite the new path mapping. Resolve the authorization and batch-existence paths before merging, unless those limitations are explicitly accepted.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "fix(wsl): read a UNC drive-mount project's files through its drive path" matches the main change. The PR maps UNC drive-mount paths such as \\wsl.localhost\Ubuntu\mnt\c\... to their Windows…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(wsl): read a UNC drive-mount project's files through its drive path" matches the main change. The PR maps UNC drive-mount paths such as \wsl.localhost\Ubuntu\mnt\c... to their Windows drive paths for filesystem reads, while keeping the UNC spelling for display and storage. The title is specific and concise, and it follows a conventional commit style.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections. The before and after behavior, the mechanism, the authorization impact, and the tests are all described. Gaps: the Linked Issue section has no issue reference (only 'Internal WSL rework'), and the 'Fixes #' line is left blank. The AI Disclosure section is empty. The Review section is empty. Several checklist items are unchecked, including the lint, typecheck, test, and build item, and the manual testing box is unchecked while the description says only macOS unit tests were run. The template asks for a linked issue for outside contributors, so the author should confirm whether that rule applies.

Resolution

Confirm whether a linked issue is required for this contributor. If it is, add the issue reference in the 'Fixes #' line. Fill in the AI Disclosure section if an AI model was used. Check the manual testing box only if manual testing was done, or explain that it was not done. Mark the pnpm lint, typecheck, test, and build item after those commands pass, or note that CI covers them.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

Major · Use the mapped Windows path for the missing-target symlink check. · filesystem-auth.ts:143

src/main/ipc/filesystem/filesystem-auth.ts:143
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Use the mapped Windows path for the missing-target symlink check.

When realpathAcrossWslDriveMount(existingAncestor) returns ENOENT, isSymlink calls lstat with the original UNC path. WSL can return EPERM for that access, and isSymlink rethrows it before checking the existing ancestor. Use windowsFsPath(path) for this filesystem check and keep the UNC path for authorization.

Suggested fix
-import { realpathAcrossWslDriveMount } from '../../wsl/wsl-unc-drive-fs-path'
+import { realpathAcrossWslDriveMount, windowsFsPath } from '../../wsl/wsl-unc-drive-fs-path'
...
-    return (await lstat(path)).isSymbolicLink()
+    return (await lstat(windowsFsPath(path))).isSymbolicLink()
Minor · Convert the path for batch existence checks. · filesystem-read-handlers.ts:158

src/main/ipc/filesystem/filesystem-read-handlers.ts:158
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Convert the path for batch existence checks.

For a registered WSL UNC drive-mount path, authorization preserves the UNC spelling after resolving through the drive path. fs:pathsExist passes that UNC path directly to stat, so a UNC EPERM returns an { error } item instead of an existence result. Apply windowsFsPath at this filesystem call.

Suggested fix
-              await stat(await resolveDesktopAuthorizedPath(filePath, store))
+              await stat(windowsFsPath(await resolveDesktopAuthorizedPath(filePath, store)))

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 928fe6c8-c42d-4fe9-abdd-477af75db6f2
Commits

Reviewing files that changed from the base of the PR and between 1ff73e8 and 9b135d6.

Files selected for processing: 10
  • src/main/ipc/filesystem/filesystem-auth.ts
  • src/main/ipc/filesystem/filesystem-path-containment.ts
  • src/main/ipc/filesystem/filesystem-read-dir-unc-drive.test.ts
  • src/main/ipc/filesystem/filesystem-read-handlers.ts
  • src/main/ipc/filesystem/filesystem-symlink-directory-entries.ts
  • src/main/ipc/hooks/register-worktree-hook-inspection-handler.ts
  • src/main/ipc/hooks/worktree-hook-inspection-unc-drive.test.ts
  • src/main/runtime/runtime-repository-hooks-commands.ts
  • src/main/wsl/wsl-unc-drive-fs-path.test.ts
  • src/main/wsl/wsl-unc-drive-fs-path.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

…ath; pin junction refusals

orca.yaml checks (hasHooksFile, loadHooks, the unknown-key probe) opened the UNC path, which WSL
2.7 refuses for drive mounts, so a saved /mnt/c project's setup hooks silently disappeared. They
now use the same drive mapping.

Also pin that authorization still judges a UNC drive-mount path against the UNC roots: a junction
under the project that resolves to another drive or outside the project is refused.
…ckage lane

Its cases need native Windows path resolution, so they skip on Linux and macOS. Gate the suite
(not each case) on win32 and register the file with the Windows lane, so CI actually runs it.
@nwparker
nwparker merged commit 61cab5e into main Oct 26, 2026
56 checks passed
nwparker added a commit that referenced this pull request Oct 26, 2026
…ough its drive path (#33756)

* fix(wsl): open, save and rename a UNC drive-mount project's files through its drive path

WSL 2.7 refuses Windows file access to its drive mounts over UNC. #33735 fixed listing a saved
\\wsl.localhost\<distro>\mnt\c\... project, but opening a file from it still failed with EPERM, as
did saving, renaming, creating and copying.

The open/read helpers (editor reads, ranged reads, media previews), the save path (write probe,
disk precondition, its locks), rename, create, copy, the file stat/exists checks, the runtime
provider used by remote clients and the document-folder realpaths now hand the filesystem the
drive path. Authorization is unchanged: it still runs on the caller's UNC spelling against the
UNC roots. Delete already runs inside the distro.

* fix(wsl): check a missing path's ancestors for links through the drive path

Authorizing a path that does not exist yet walks up to the nearest existing folder and refuses a
dangling link on the way; that link check ran lstat on the UNC spelling, which WSL 2.7 refuses for
drive mounts. So New File, New Folder, a first save, an upload and a copy or rename into a new
folder all failed with EPERM (failing closed). The check now lstats the drive path, where Windows
still reports junctions and symlinks.
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.

1 participant