fix: tolerate Bun's spurious EEXIST from recursive mkdir on Windows ReadOnly dirs#2329
Open
Vaughan-g-aus wants to merge 1 commit into
Open
fix: tolerate Bun's spurious EEXIST from recursive mkdir on Windows ReadOnly dirs#2329Vaughan-g-aus wants to merge 1 commit into
Vaughan-g-aus wants to merge 1 commit into
Conversation
…eadOnly dirs
On Windows, Bun (reproduced on 1.3.11) throws EEXIST from
fs.mkdirSync(dir, { recursive: true }) when the directory already exists
AND carries FILE_ATTRIBUTE_READONLY - an attribute Explorer sets as a
"customized folder" marker that does not actually prevent writes. Node
treats the identical call as a no-op success.
gen-skill-docs.ts hits this in two places on affected machines: the
section-template mkdir (ship/sections is a committed dir) fails Claude
generation, and the per-host output mkdir fails every external host, so
`gen:skill-docs --host all` exits 1 and ./setup aborts.
Add mkdirpSync(): swallow EEXIST only after stat confirms an existing
directory (a collision with a regular file still throws), and use it at
every mkdir site in gen-skill-docs.ts and gen-llms-txt.ts.
Verified on Windows 11 / Bun 1.3.11: with ReadOnly set on ship/sections
and .agents/skills/gstack, --host claude and --host codex both fail
before this change and succeed after; a file-collision still throws.
Related: garrytan#2048 (same Bun EEXIST class in browse/mkdirSecure).
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Author
|
/trunk merge |
|
An error occurred while submitting your PR to the queue: |
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.
Problem
On Windows, Bun (reproduced on 1.3.11) throws
EEXISTfromfs.mkdirSync(dir, { recursive: true })when the directory already exists andcarries
FILE_ATTRIBUTE_READONLY— an attribute Explorer sets as a "customizedfolder" marker that does not actually prevent writes. Node treats the identical
call as a no-op success.
On affected machines
./setupcannot complete:gen-skill-docs.tsfails Claude generation at the section-template mkdir(
ship/sectionsis a committed directory):WARNING: claude generation failed: EEXIST: file already exists, mkdir '...\ship\sections'(e.g.
.agents/skills/gstackfrom a prior run), so--host allreports10 host(s) failed, exits 1, andset -eaborts setup.This is the same Bun EEXIST class already tracked in #2048 (
browse/mkdirSecure).Bun refs: oven-sh/bun#16466 fixed the plain-existing-dir variant; the ReadOnly
variant still reproduces on 1.3.11.
Fix
Add
scripts/fs-utils.tswithmkdirpSync()— a drop-in for recursivemkdirSyncthat swallowsEEXISTonly afterstatSyncconfirms the path is anexisting directory (a collision with a regular file still throws, and there is
no exists-check race). Use it at every mkdir site in
gen-skill-docs.ts(5 sites)and
gen-llms-txt.ts(1 site).Verification (Windows 11, Bun 1.3.11)
--host claudewith ReadOnly onship/sectionsclaude generation failed: EEXISTGENERATED: SKILL.md…--host codexwith ReadOnly on.agents/skills/gstackcodex generation failed: EEXISTThe branch is based on
7c9df1c(v1.60.1.0); the touched files are unchanged oncurrent
main, so it merges cleanly there too.