-
Notifications
You must be signed in to change notification settings - Fork 427
fix: detect MiKTeX in quarto check on Windows
#14266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -414,8 +414,23 @@ async function checkInstall(conf: CheckConfiguration) { | |
| latexOutput.push(`${kIndent}Version: ${version}`); | ||
| latexJson["version"] = version; | ||
| } else { | ||
| latexOutput.push(`${kIndent}Tex: (not detected)`); | ||
| latexJson["installed"] = false; | ||
| // Check for MiKTeX (uses initexmf instead of tlmgr) | ||
| const miktexDetection = await detectMiktex(); | ||
| if (miktexDetection) { | ||
| latexOutput.push(`${kIndent}Using: MiKTeX`); | ||
| if (miktexDetection.path) { | ||
| latexOutput.push(`${kIndent}Path: ${miktexDetection.path}`); | ||
| latexJson["path"] = miktexDetection.path; | ||
| } | ||
| latexJson["source"] = "miktex"; | ||
| if (miktexDetection.version) { | ||
| latexOutput.push(`${kIndent}Version: ${miktexDetection.version}`); | ||
| latexJson["version"] = miktexDetection.version; | ||
| } | ||
| } else { | ||
| latexOutput.push(`${kIndent}Tex: (not detected)`); | ||
| latexJson["installed"] = false; | ||
| } | ||
| } | ||
| }; | ||
| if (conf.jsonResult) { | ||
|
|
@@ -561,3 +576,50 @@ async function detectChromeForCheck(): Promise<ChromeCheckInfo> { | |
|
|
||
| return result; | ||
| } | ||
|
|
||
| interface MiktexDetectionResult { | ||
| path?: string; | ||
| version?: string; | ||
| } | ||
|
|
||
| async function detectMiktex(): Promise<MiktexDetectionResult | undefined> { | ||
| try { | ||
| const initexmfPath = await which("initexmf"); | ||
| if (!initexmfPath) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const result: MiktexDetectionResult = { | ||
| path: dirname(initexmfPath), | ||
| }; | ||
|
|
||
| // Get MiKTeX version via initexmf --version | ||
| try { | ||
| const versionResult = await execProcess({ | ||
| cmd: "initexmf", | ||
| args: ["--version"], | ||
| stdout: "piped", | ||
| stderr: "piped", | ||
| }); | ||
| if (versionResult.code === 0 && versionResult.stdout) { | ||
| // 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]; | ||
| } | ||
|
Comment on lines
+605
to
+615
|
||
| } | ||
| } catch { | ||
| // Version detection is best-effort | ||
| } | ||
|
|
||
| return result; | ||
| } catch { | ||
| return undefined; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detectMiktex()recordspathbased on the resolvedinitexmfPath, but the version check runsexecProcesswithcmd: "initexmf"(re-resolved from PATH). If multipleinitexmfentries exist (or PATH changes), this can report a path from one install and a version from another. Use the resolvedinitexmfPathfor theexecProcesscall (and/or setcwdappropriately) to keep path/version consistent.