Skip to content

Fix LaTeX "(file ...): cannot open" missing-file detection - #15385

Merged
cderv merged 1 commit into
mainfrom
fix/parse-error-ts-file-cannot-open-package-matcher-is-double-escaped-and-never-matches
Nov 17, 2026
Merged

cderv merged 1 commit into
mainfrom
fix/parse-error-ts-file-cannot-open-package-matcher-is-double-escaped-and-never-matches

Conversation

@cderv

@cderv cderv commented Nov 17, 2026

Copy link
Copy Markdown
Member

When a LaTeX compile fails, Quarto scans the log for files it can auto-install from TeX Live. The pattern for messages like pdflatex (file 8r.enc): cannot open encoding file for reading never matched anything, so that file was not detected from this message.

Root cause

The pattern came from tinytex's R/latex.R, where the R string '.* \\(file ([^)]+)\\): cannot open .*' means the regex \( (a literal parenthesis). It was copied as-is into a JavaScript regex literal in src/command/render/latexmk/parse-error.ts, where \\( means a literal backslash followed by a group. The pattern then requires a backslash before (file that never appears in a log.

The existing test kept passing because its log line starts with !pdfTeX error:, and a separate font pattern also catches (file ...) in lines with a ! ... error: prefix. Lines without that prefix were missed.

Fix

Use a single backslash, matching tinytex's regex. A new unit test covers the message without the ! ... error: prefix.

Found while working on #15376.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone, tinytex source read via GitHub API
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

The pattern was copied from tinytex's R source, where the string
'.* \\(file ([^)]+)\\): cannot open .*' denotes the regex \(. Pasted
into a JS regex literal, \\( instead requires a literal backslash before
"(file", so the matcher never matched a real log line.

The existing "!pdfTeX error: ... (file 8r.enc): cannot open ..." test kept
passing because the font matcher also catches lines with a "! ... error:"
prefix. The new test covers the same message without that prefix.
@posit-snyk-bot

posit-snyk-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

✅ 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 69936dd into main Nov 17, 2026
52 checks passed
@cderv
cderv deleted the fix/parse-error-ts-file-cannot-open-package-matcher-is-double-escaped-and-never-matches branch November 17, 2026 11:36
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.

2 participants