fix(create-astro): scaffold into the correct directory when the path contains non-ASCII characters#17386
Open
felmonon wants to merge 2 commits into
Open
fix(create-astro): scaffold into the correct directory when the path contains non-ASCII characters#17386felmonon wants to merge 2 commits into
felmonon wants to merge 2 commits into
Conversation
…inux modern-tar normalizes all paths containing non-ASCII characters to NFD (decomposed Unicode), which on Linux ext4 creates a separate directory from the user's NFC-encoded original. This caused template files to silently end up in the wrong directory while create-astro reported success. After downloadTemplate completes, check if an NFD-variant directory was created and move its contents back to the intended NFC directory. Fixes withastro#17381
🦋 Changeset detectedLatest commit: 2155be8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Changes
Fixes #17381.
pnpm create astrosilently scaffolds into the wrong directory on Linux when the project path contains non-ASCII characters (e.g./home/user/Masaüstü/). The root cause is inmodern-tar(transitive via@bluwy/giget-core): itsnormalizeUnicodehelper NFD-normalizes any non-ASCII string, andvalidateBoundsapplies that to the resolved destination path — not just tar entry names. On byte-preserving filesystems (ext4 and friends) NFC and NFD are distinct paths, so the template lands in a parallel decomposed-form directory tree while the CLI exits 0. Details in my triage comment on the issue.This PR adds
relocateNFDFiles(), called afterdownloadTemplate(): if an NFD-variant of the target directory exists and is a distinct directory (inode check, so normalization-transparent filesystems like APFS/HFS+ are a no-op), its contents are moved back to the intended NFC path and the empty NFD directory chain is removed. The upwardrmdirwalk stops at the first shared ancestor, which is guaranteed non-empty because the real NFC target lives inside it.The fix and test originate from the triage bot's exploration branch (
triagebot/fix-17381, cherry-picked with authorship preserved); I verified the root cause independently againstmodern-tar's source, reviewed the relocation/cleanup logic, and added the missing changeset.A create-astro-side relocation is a mitigation — the durable fix belongs upstream in
modern-tar(NFD-normalizing tar entry names for comparison is defensible; rewriting the destination path's Unicode form is not). Happy to open an upstream issue there as a follow-up, but create-astro users are broken today.Testing
New unit test
packages/create-astro/test/units/relocate-nfd.test.tscovers the move-and-cleanup path, the ASCII no-op, and the missing-NFD-dir no-op. Note the suite self-skips on normalization-transparent filesystems (macOS), so the meaningful assertions execute on the Linux CI runners — which is also the only platform where the bug reproduces.Docs
n/a — bug fix, no behavior change for correctly-scaffolded projects. Changeset included.