Skip to content

Commit 680415e

Browse files
committed
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
1 parent af0bb42 commit 680415e

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ All changes included in 1.9:
4646
- ([#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.
4747
- ([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.
4848
- ([#13667](https://github.com/quarto-dev/quarto-cli/issues/13667)): Fix LaTeX compilation error with Python error output containing caret characters.
49+
- ([#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.
4950

5051
## Projects
5152

src/tools/impl/tinytex-info.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ import { existsSync } from "../../deno_ral/fs.ts";
1212
import { os as platformOs } from "../../deno_ral/platform.ts";
1313

1414
export function hasTinyTex(): boolean {
15-
const installDir = tinyTexInstallDir();
16-
if (installDir && existsSync(installDir)) {
17-
return true;
18-
} else {
19-
return false;
15+
const binDir = tinyTexBinDir();
16+
if (!binDir) {
17+
return false; // No bin directory found
2018
}
19+
20+
// Check for tlmgr binary (critical package manager)
21+
const tlmgrBinary = platformOs === "windows" ? "tlmgr.bat" : "tlmgr";
22+
const tlmgrPath = join(binDir, tlmgrBinary);
23+
return safeExistsSync(tlmgrPath);
2124
}
2225

2326
export function tinyTexInstallDir(): string | undefined {
@@ -49,10 +52,16 @@ export function tinyTexBinDir(): string | undefined {
4952
if (safeExistsSync(winPath)) return winPath;
5053
return join(basePath, "bin\\windows\\");
5154
}
52-
case "linux":
53-
return join(basePath, `bin/${Deno.build.arch}-linux`);
54-
case "darwin":
55-
return join(basePath, "bin/universal-darwin");
55+
case "linux": {
56+
const linuxPath = join(basePath, `bin/${Deno.build.arch}-linux`);
57+
if (safeExistsSync(linuxPath)) return linuxPath;
58+
return undefined;
59+
}
60+
case "darwin": {
61+
const darwinPath = join(basePath, "bin/universal-darwin");
62+
if (safeExistsSync(darwinPath)) return darwinPath;
63+
return undefined;
64+
}
5665
default:
5766
return undefined;
5867
}

0 commit comments

Comments
 (0)