fix: normalize Unicode paths to NFC for macOS compatibility#82
Merged
fix: normalize Unicode paths to NFC for macOS compatibility#82
Conversation
Replace Bun.file() async calls with Node.js fs sync methods to work around a Bun bug that corrupts UTF-8 file paths containing non-ASCII characters. Bug: Bun.file(filepath).stat() and Bun.file(filepath).text() internally mangle UTF-8 encoding, causing ENOENT errors with mojibake paths when accessing files in iCloud Drive and other locations. Changes: - src/qmd.ts: Use readFileSync instead of Bun.file().text() - src/qmd.ts: Use statSync instead of Bun.file().stat() for file metadata - src/store.ts: Use statSync for SQLite custom path detection
86f455a to
da9d1c3
Compare
Anrahya
pushed a commit
to Anrahya/qmd
that referenced
this pull request
Feb 3, 2026
Replace Bun.file() async calls with Node.js fs sync methods to work around a Bun bug that corrupts UTF-8 file paths containing non-ASCII characters. Bug: Bun.file(filepath).stat() and Bun.file(filepath).text() internally mangle UTF-8 encoding, causing ENOENT errors with mojibake paths when accessing files in iCloud Drive and other locations. Changes: - src/qmd.ts: Use readFileSync instead of Bun.file().text() - src/qmd.ts: Use statSync instead of Bun.file().stat() for file metadata - src/store.ts: Use statSync for SQLite custom path detection
jaylfc
added a commit
to jaylfc/qmd
that referenced
this pull request
Apr 5, 2026
Replace Bun.file() async calls with Node.js fs sync methods to work around a Bun bug that corrupts UTF-8 file paths containing non-ASCII characters. Bug: Bun.file(filepath).stat() and Bun.file(filepath).text() internally mangle UTF-8 encoding, causing ENOENT errors with mojibake paths when accessing files in iCloud Drive and other locations. Changes: - src/qmd.ts: Use readFileSync instead of Bun.file().text() - src/qmd.ts: Use statSync instead of Bun.file().stat() for file metadata - src/store.ts: Use statSync for SQLite custom path detection
jaylfc
added a commit
to jaylfc/qmd
that referenced
this pull request
Apr 5, 2026
Replace Bun.file() async calls with Node.js fs sync methods to work around a Bun bug that corrupts UTF-8 file paths containing non-ASCII characters. Bug: Bun.file(filepath).stat() and Bun.file(filepath).text() internally mangle UTF-8 encoding, causing ENOENT errors with mojibake paths when accessing files in iCloud Drive and other locations. Changes: - src/qmd.ts: Use readFileSync instead of Bun.file().text() - src/qmd.ts: Use statSync instead of Bun.file().stat() for file metadata - src/store.ts: Use statSync for SQLite custom path detection
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.
Summary
Workaround for Bun UTF-8 path corruption bug in
Bun.file().stat()that causes ENOENT errors when indexing files with non-ASCII characters.Bug Discovery
Only
Bun.file().stat()is affected. Investigation revealed:Bun.file(path).stat()- BROKEN - corrupts UTF-8 paths internallyBun.file(path).text()- WORKS - uses different code path, not affectedThe bug causes mojibake when Bun converts the JavaScript string to a system call path, resulting in ENOENT errors for files with non-ASCII characters (e.g., German umlauts like ö, ü, ä).
Changes
While only
.stat()was buggy, we standardized on Node.jsfsmodule for consistency:statSync()instead ofBun.file().stat()(fixes the bug)readFileSync()instead ofBun.file().text()(for API consistency)statSync()for SQLite custom path detectionImpact
Future Work
These workarounds can be reverted once Bun fixes the UTF-8 path handling in
Bun.file().stat().Test Plan
Fixes #81