From 680415ea14d77a3cbf9a010624c0f563fc91c65d Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 1 Dec 2025 16:02:10 +0100 Subject: [PATCH] Fix TinyTeX detection for empty directories Quarto was incorrectly detecting TinyTeX when ~/.TinyTeX/ directory existed without binaries, reporting "Version: undefined" but marking the check as OK. This prevented fallback to valid TinyTeX installations in the system PATH. The detection logic now validates both that the bin directory exists and contains the tlmgr binary before reporting TinyTeX as available. Fixes #13730 --- news/changelog-1.9.md | 1 + src/tools/impl/tinytex-info.ts | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index fddba772d99..0e18e2b0d10 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -46,6 +46,7 @@ All changes included in 1.9: - ([#13661](https://github.com/quarto-dev/quarto-cli/issues/13661)): Fix LaTeX compilation errors when using `mermaid-format: svg` with PDF/LaTeX output. SVG diagrams are now written directly without HTML script tags. Note: `mermaid-format: png` is recommended for best compatibility. SVG format requires `rsvg-convert` (or Inkscape with `use-rsvg-convert: false`) in PATH for conversion to PDF, and may experience text clipping in diagrams with multi-line labels. - ([rstudio/tinytex-releases#49](https://github.com/rstudio/tinytex-releases/issues/49)): Fix detection of LuaTeX-ja missing file errors by matching both "File" and "file" in error messages. - ([#13667](https://github.com/quarto-dev/quarto-cli/issues/13667)): Fix LaTeX compilation error with Python error output containing caret characters. +- ([#13730](https://github.com/quarto-dev/quarto-cli/issues/13730)): Fix TinyTeX detection when `~/.TinyTeX/` directory exists without binaries. Quarto now verifies that the bin directory and tlmgr binary exist before reporting TinyTeX as available, allowing proper fallback to system PATH installations. ## Projects diff --git a/src/tools/impl/tinytex-info.ts b/src/tools/impl/tinytex-info.ts index b0b9f6d487e..826d4e32318 100644 --- a/src/tools/impl/tinytex-info.ts +++ b/src/tools/impl/tinytex-info.ts @@ -12,12 +12,15 @@ import { existsSync } from "../../deno_ral/fs.ts"; import { os as platformOs } from "../../deno_ral/platform.ts"; export function hasTinyTex(): boolean { - const installDir = tinyTexInstallDir(); - if (installDir && existsSync(installDir)) { - return true; - } else { - return false; + const binDir = tinyTexBinDir(); + if (!binDir) { + return false; // No bin directory found } + + // Check for tlmgr binary (critical package manager) + const tlmgrBinary = platformOs === "windows" ? "tlmgr.bat" : "tlmgr"; + const tlmgrPath = join(binDir, tlmgrBinary); + return safeExistsSync(tlmgrPath); } export function tinyTexInstallDir(): string | undefined { @@ -49,10 +52,16 @@ export function tinyTexBinDir(): string | undefined { if (safeExistsSync(winPath)) return winPath; return join(basePath, "bin\\windows\\"); } - case "linux": - return join(basePath, `bin/${Deno.build.arch}-linux`); - case "darwin": - return join(basePath, "bin/universal-darwin"); + case "linux": { + const linuxPath = join(basePath, `bin/${Deno.build.arch}-linux`); + if (safeExistsSync(linuxPath)) return linuxPath; + return undefined; + } + case "darwin": { + const darwinPath = join(basePath, "bin/universal-darwin"); + if (safeExistsSync(darwinPath)) return darwinPath; + return undefined; + } default: return undefined; }