|
7 | 7 | import { Command } from "cliffy/command/mod.ts"; |
8 | 8 | import { join } from "../../../src/deno_ral/path.ts"; |
9 | 9 | import { ensureDirSync } from "../../../src/deno_ral/fs.ts"; |
10 | | -import { error, info, warning } from "../../../src/deno_ral/log.ts"; |
| 10 | +import { error, info } from "../../../src/deno_ral/log.ts"; |
11 | 11 |
|
12 | 12 | import { |
13 | 13 | Configuration, |
@@ -72,32 +72,42 @@ export function updatePandoc() { |
72 | 72 | throw new Error("QUARTO_PANDOC is not set"); |
73 | 73 | } |
74 | 74 |
|
75 | | - // Best-effort sanity check: warn (do not fail) if the override binary |
76 | | - // does not report the requested version. Version-string formatting can |
77 | | - // differ (e.g. a trailing .0), so a mismatch is a warning, not an error. |
| 75 | + // Fatal check: pandocBinaryPath() silently falls back to the bundled/ |
| 76 | + // configured Pandoc (with only a warnOnce) if QUARTO_PANDOC is unset, |
| 77 | + // nonexistent, or otherwise fails to resolve (src/core/resources.ts |
| 78 | + // toolsPath()). If the resolved binary doesn't report the requested |
| 79 | + // version, continuing would regenerate format-extension.ts from the |
| 80 | + // wrong (likely old, bundled) Pandoc - the exact silent corruption |
| 81 | + // this flag exists to prevent - so this must fail, not warn. |
| 82 | + let reported: string | undefined; |
78 | 83 | try { |
79 | | - const reported = lines( |
| 84 | + reported = lines( |
80 | 85 | (await execProcess({ |
81 | 86 | cmd: pandocBinaryPath(), |
82 | 87 | args: ["--version"], |
83 | 88 | stdout: "piped", |
84 | 89 | })).stdout!, |
85 | 90 | )[0]?.split(" ")[1]; |
86 | | - if ( |
87 | | - normalizePandocVersion(reported) !== normalizePandocVersion(version) |
88 | | - ) { |
89 | | - warning( |
90 | | - `QUARTO_PANDOC reports Pandoc ${reported}, but --skip-archive was ` + |
91 | | - `asked to update to ${version}. Continuing, but double-check that ` + |
92 | | - "QUARTO_PANDOC points at the intended binary.", |
93 | | - ); |
94 | | - } |
95 | 91 | } catch (_e) { |
96 | | - warning( |
97 | | - "Could not read the QUARTO_PANDOC binary version for the pre-flight " + |
98 | | - "check; continuing. writeVariants() will fail below if the binary is " + |
99 | | - "not runnable.", |
| 92 | + error( |
| 93 | + "Could not run the QUARTO_PANDOC binary to verify its version. " + |
| 94 | + `QUARTO_PANDOC is set to "${overridePath}" - confirm it points at a ` + |
| 95 | + "runnable Pandoc executable.", |
| 96 | + ); |
| 97 | + throw new Error("QUARTO_PANDOC binary is not runnable"); |
| 98 | + } |
| 99 | + if ( |
| 100 | + normalizePandocVersion(reported) !== normalizePandocVersion(version) |
| 101 | + ) { |
| 102 | + error( |
| 103 | + `The Pandoc binary resolved via QUARTO_PANDOC reports version ` + |
| 104 | + `${reported}, not the requested ${version}. QUARTO_PANDOC is set to ` + |
| 105 | + `"${overridePath}" - if that path doesn't exist or isn't a file, ` + |
| 106 | + "pandocBinaryPath() silently fell back to the bundled/configured " + |
| 107 | + "Pandoc, which would corrupt format-extension.ts if this continued. " + |
| 108 | + "Fix QUARTO_PANDOC and retry.", |
100 | 109 | ); |
| 110 | + throw new Error("QUARTO_PANDOC does not resolve to the requested version"); |
101 | 111 | } |
102 | 112 | } else { |
103 | 113 | // Update the configuration file |
|
0 commit comments