Skip to content

Fix Windows dart-sass failures with accented paths and enterprise .bat blocking#14273

Merged
cderv merged 7 commits intomainfrom
fix/issue-14267
Mar 27, 2026
Merged

Fix Windows dart-sass failures with accented paths and enterprise .bat blocking#14273
cderv merged 7 commits intomainfrom
fix/issue-14267

Conversation

@cderv
Copy link
Copy Markdown
Collaborator

@cderv cderv commented Mar 26, 2026

On Windows, dart-sass compilation fails when user paths contain accented characters (e.g., C:\Users\Sébastien\). The safeWindowsExec wrapper introduced in v1.9 writes temp .bat files as UTF-8, but cmd.exe reads them using the OEM code page (CP850), garbling multi-byte characters like é.

Separately, enterprise environments that block .bat execution via group policy cannot run dart-sass at all, since it is invoked through sass.bat.

Root Cause

safeWindowsExec uses Deno.writeTextFileSync (UTF-8 default) to write a temp .bat file, then runs it via cmd /c. On systems with OEM code page 850, UTF-8 multi-byte sequences (e.g., é = 0xC3 0xA9) are misinterpreted as two CP850 characters, producing "file name syntax incorrect" errors.

Fix

Two changes, ordered for backportability:

  1. Harden safeWindowsExec — prepend chcp 65001 >nul to generated .bat files so cmd.exe uses UTF-8. Uses CRLF line endings for correct batch parsing. This is the minimal, backportable fix for the encoding regression.

  2. Bypass sass.bat entirely — on Windows, call dart.exe + sass.snapshot directly via Deno.Command/execProcess instead of going through sass.bat. This eliminates the entire class of .bat file issues (encoding, Deno quoting bugs, enterprise policy blocking). Follows the pattern already used by verapdf.ts.

QUARTO_DART_SASS env var override (used by conda) continues to work as before — it points to a native sass.exe, not a .bat.

Fixes #14267, fixes #6651

cderv added 5 commits March 26, 2026 13:02
safeWindowsExec writes temp .bat files as UTF-8 (Deno default), but
cmd.exe reads them using the OEM code page (e.g., CP850). Multi-byte
UTF-8 characters like é (0xC3 0xA9) get misinterpreted, breaking
paths with accented characters (e.g., C:\Users\Sébastien\).

Add `chcp 65001 >nul` to switch cmd.exe to UTF-8 before the command
line is parsed. Use CRLF line endings for correct .bat parsing.
Instead of invoking sass.bat through safeWindowsExec (which creates a
temp .bat file via cmd /c), call dart.exe + sass.snapshot directly.
This eliminates three classes of Windows .bat file issues:

- Deno quoting bug with spaced paths (#13997)
- cmd.exe OEM code page misreading UTF-8 accented paths (#14267)
- Enterprise group policy blocking .bat execution (#6651)

Follows the pattern established by verapdf.ts which bypasses its .bat
wrapper for the same reasons.
Explicit installDir option (used by tests) should take precedence over
QUARTO_DART_SASS env var, matching the previous sassPath behavior.
cderv added 2 commits March 26, 2026 15:59
Add upstream references for sass.bat template and dart_cli_pkg#67.
Rename installDir back to sassPath for consistency with QUARTO_DART_SASS.
@cderv cderv merged commit 4a7b6ce into main Mar 27, 2026
51 checks passed
@cderv cderv deleted the fix/issue-14267 branch March 27, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant