Skip to content

fix(latex): treat fmtutil-sys failure as non-fatal during package install#14490

Merged
cderv merged 7 commits into
mainfrom
fix/issue-14461
May 6, 2026
Merged

fix(latex): treat fmtutil-sys failure as non-fatal during package install#14490
cderv merged 7 commits into
mainfrom
fix/issue-14461

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented May 6, 2026

When quarto render --to pdf triggered automatic LaTeX package installation and the post-update fmtutil-sys --all step exited non-zero, the entire render aborted with ERROR: Problem running 'fmtutil-sys --all' to rebuild format tree. even though the package install itself had already succeeded (or was about to be retried).

Root Cause

Both recovery branches in installPackage (src/command/render/latexmk/texlive.ts) reject when fmtutil-sys exits non-zero. The fmtutil-sys --all call was added in #7252 to mitigate l3kernel version mismatches after tlmgr update --all, mirroring upstream tinytex R behavior — but the upstream tinytex discards the system2('fmtutil', ...) exit code (R/tlmgr.R, R/latex.R). Quarto's port treats it as fatal instead.

fmtutil-sys failures are environment-specific (locale, antivirus, transient locks, format-tree state) and unrelated to whether the package install succeeded. Format-tree rebuild is best-effort housekeeping.

Fix

installPackage now logs a warning via a small fmtutilFailureMessage(result) helper and continues, matching upstream behavior. Unit tests cover the helper (tests/unit/latexmk/fmtutil-handler.test.ts).

fmtutilCommand is also routed through safeWindowsExec on Windows (mirrors tlmgrCommand) as defense against runscript.tlu short-path resolution failures (rstudio/tinytex#427). The program path + args are pre-quoted via requireQuoting per the documented safeWindowsExec - handles program path with spaces test (#13997). A new rule doc (.claude/rules/typescript/windows-safe-exec.md) captures the requireQuoting-before-safeWindowsExec convention so future call sites pick it up by default.

Out of scope: pdf.ts calls pkgMgr.updatePackages(true, false) outside installPackage without ever running fmtutil — pre-existing gap unrelated to the abort behavior fixed here.

Fixes #14461

cderv added 7 commits May 6, 2026 13:32
Returns a warning message when `fmtutil-sys --all` exits non-zero, or
undefined on success. Lets callers log a warning and continue rather
than aborting. Matches the upstream tinytex R package pattern, which
ignores the `fmtutil` exit code.

Refs: #14461
Both recovery branches in `installPackage` previously aborted the
render with `Problem running fmtutil-sys --all to rebuild format
tree.` whenever fmtutil exited non-zero. Format-tree rebuild is
best-effort housekeeping after `tlmgr update`; the package install
itself has already succeeded by that point. Log a warning and
continue, mirroring upstream tinytex R behavior.

Fixes #14461
Mirrors the `tlmgrCommand` pattern: invoke through a temp .bat with
`cmd /c`. Defends against 8.3 short-path resolution failures inside
TeX Live's `runscript.tlu` (rstudio/tinytex#427) when Deno spawns the
process directly.

Refs: #14461
`safeWindowsExec` joins program + args into a `.bat` command line with
literal spaces, so paths containing spaces would be tokenized
incorrectly (e.g. `C:\Users\Jane Doe\...`). Mirrors the documented
pattern from the `safeWindowsExec - handles program path with spaces`
unit test (#13997).

Refs: #14461
Captures the pattern hit while wiring fmtutil-sys: `safeWindowsExec`
needs `requireQuoting` on both program path and args, otherwise the
generated .bat tokenizes incorrectly when paths contain spaces. Points
to the #13997 test and existing call sites as authoritative refs.
Earlier wording implied tlmgr/fmtutil/reg.exe were the full set; `zip.ts`
and `shell.ts` are also callers. Reframe as examples + tell readers to
grep when they need the current list.
@posit-snyk-bot
Copy link
Copy Markdown
Collaborator

posit-snyk-bot commented May 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv cderv merged commit 27b4a5b into main May 6, 2026
51 checks passed
@cderv cderv deleted the fix/issue-14461 branch May 6, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows ERROR: Problem running fmtutil-sys --all to rebuild format tree.

2 participants