Repository navigation
fix(windows): resolve paths with the native realpath - #53509
Closed
ReinisLusis wants to merge 1 commit into
Closed
ReinisLusis wants to merge 1 commit into
ReinisLusis wants to merge 1 commit into
Conversation
Filesystem.resolve and FSUtil.resolve called the JS realpathSync, which on Windows lstats every ancestor starting at the drive root. A process that cannot read attributes of the drive root, such as one in an AppContainer without capabilities, fails at startup with "EPERM: operation not permitted, lstat 'C:\'". On Windows, use realpathSync.native, which opens only the target. ENOENT keeps the existing fallback; any other native failure falls back to the JS realpath as before. normalizePath already passes the result through the native call, so resolved paths are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
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.
Issue for this PR
Closes #53508
Type of change
What does this PR do?
On Windows,
Filesystem.resolveandFSUtil.resolvecall the JSrealpathSync, whichlstats the drive root and every ancestor. A process that cannot readC:\(for example an AppContainer with no capabilities) exits at startup withEPERM: operation not permitted, lstat 'C:\'.On Windows these helpers now call
realpathSync.native, which opens only the target.ENOENTkeeps the existing fallback to the unresolved path. Any other native failure falls back to the JSrealpathSync, which throws its errors as before. Other platforms are unchanged.Resolved paths do not change:
normalizePathalready passes the result throughrealpathSync.nativeon Windows. I compared old and new output on Windows for a plain folder, a lowercased path, an 8.3 short path, a junction, asubstdrive and its root, and a missing path; all matched. A mapped network drive was not available to test; it takes the same native call throughnormalizePathtoday.Effect's
FileSystem.realPath(used by the EffectFSUtil.resolve, see #52458) is not changed here.How did you verify your code works?
packages/opencode/test/util/filesystem.test.tsandpackages/core/test/filesystem/filesystem.test.ts: a junction resolves through the native call, and a failing native call falls back to the JS realpath. The junction test fails without this change.bun test test/util/filesystem.test.ts(opencode): 61 pass; the 2 existing symlink tests fail on this machine atfs.symlink(no symlink privilege), before and after the change.bun test test/filesystem/filesystem.test.ts(core): 29 pass.bun run typecheckpasses in both packages.resolvebody throwsEPERM ... lstat 'C:\'; the new body returns the folder path, and theENOENTfallback for a missing child also works.Found while running OpenCode inside a Windows AppContainer sandbox.
Screenshots / recordings
Not a UI change.
Checklist
🤖 Generated with Claude Code