Skip to content

fix: detect MiKTeX in quarto check on Windows#14266

Closed
queelius wants to merge 1 commit intoquarto-dev:mainfrom
queelius:fix/14265-miktex-detection
Closed

fix: detect MiKTeX in quarto check on Windows#14266
queelius wants to merge 1 commit intoquarto-dev:mainfrom
queelius:fix/14265-miktex-detection

Conversation

@queelius
Copy link
Copy Markdown

Summary

  • Add MiKTeX detection as a fallback when TeX Live/TinyTeX are not found in quarto check
  • Detect MiKTeX by locating initexmf in PATH and extracting version from its --version output
  • Populate both human-readable output and JSON result with MiKTeX path, version, and source

Closes #14265

Details

On Windows, quarto check reported Tex: (not detected) even when MiKTeX was installed, in PATH, and successfully used for PDF compilation. The existing LaTeX detection only checked for TeX Live (via tlmgr) and TinyTeX. MiKTeX uses initexmf as its configuration utility rather than tlmgr, so it was never found.

The fix adds a detectMiktex() function that:

  1. Checks if initexmf is available via which
  2. Extracts the installation path from initexmf's location
  3. Parses the MiKTeX distribution version from initexmf --version output (e.g., MiKTeX 26.2)

After the fix, users with MiKTeX will see:

Checking LaTeX...OK
  Using: MiKTeX
  Path: C:/Program Files/MiKTeX/miktex/bin/x64
  Version: 26.2

Test plan

  • Verify on Windows with MiKTeX installed: quarto check shows MiKTeX info
  • Verify on Windows with TeX Live installed: behavior unchanged (TeX Live detected first)
  • Verify on Windows with neither installed: still shows (not detected)
  • Verify quarto check --output check.json includes "source": "miktex" in JSON output
  • Verify existing CI tests pass (no behavioral change on Linux/macOS without MiKTeX)

🤖 Generated with Claude Code

Previously, `quarto check` only looked for TeX Live (via tlmgr) and
TinyTeX when checking for LaTeX installations. MiKTeX, which uses
`initexmf` instead of `tlmgr`, was never detected -- even when
installed, in PATH, and successfully used for PDF compilation.

Add a MiKTeX detection fallback that runs when TeX Live is not found.
It locates `initexmf` in PATH and extracts the MiKTeX distribution
version from its --version output.

Closes quarto-dev#14265

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 25, 2026 07:44
@posit-snyk-bot
Copy link
Copy Markdown
Collaborator

posit-snyk-bot commented Mar 25, 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds MiKTeX as an additional LaTeX distribution that quarto check can detect (primarily for Windows), so users no longer see Tex: (not detected) when MiKTeX is installed and on PATH.

Changes:

  • Add MiKTeX fallback detection by locating initexmf and extracting a distribution version from initexmf --version.
  • Populate quarto check human-readable output and JSON output with MiKTeX path/version/source when detected.
  • Document the fix in the 1.10 changelog.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/command/check/check.ts Adds MiKTeX detection fallback and JSON/output population for quarto check LaTeX checks.
news/changelog-1.10.md Adds a changelog entry noting MiKTeX detection fix for quarto check on Windows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +598 to +603
const versionResult = await execProcess({
cmd: "initexmf",
args: ["--version"],
stdout: "piped",
stderr: "piped",
});
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detectMiktex() records path based on the resolved initexmfPath, but the version check runs execProcess with cmd: "initexmf" (re-resolved from PATH). If multiple initexmf entries exist (or PATH changes), this can report a path from one install and a version from another. Use the resolved initexmfPath for the execProcess call (and/or set cwd appropriately) to keep path/version consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +605 to +615
// initexmf --version outputs lines like:
// MiKTeX Configuration Utility 4.12 (MiKTeX 24.1)
// The parenthesized version is the distribution version
const distVersionMatch = versionResult.stdout.match(
/\(MiKTeX\s+(\d[\d.]*)\)/i,
);
const versionMatch = distVersionMatch ||
versionResult.stdout.match(/MiKTeX\s+(\d[\d.]*)/i);
if (versionMatch) {
result.version = versionMatch[1];
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new MiKTeX version parsing logic is currently untested. There are existing smoke tests for quarto check --output (JSON parsing) but nothing exercises/validates the MiKTeX detection/version extraction path; consider adding a unit test for the initexmf --version parsing (and ideally path/source population) to prevent regressions when MiKTeX changes its output format.

Copilot uses AI. Check for mistakes.
@mcanouil
Copy link
Copy Markdown
Collaborator

mcanouil commented Mar 25, 2026

@queelius before asking Claude to fix things, better to understand the issue and look for related discussions.

@queelius
Copy link
Copy Markdown
Author

Closing this. After reading through #13484 and #13480, I can see this needs a broader approach (generic TeX engine detection on PATH rather than MiKTeX-specific). I should have checked the related discussions before submitting. Apologies for the noise.

@queelius queelius closed this Mar 25, 2026
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.

quarto check does not detect MiKTeX on Windows even when available in system PATH

4 participants