Skip to content

Commit d7e1e82

Browse files
committed
Make QUARTO_PANDOC version mismatch fatal in --skip-archive
toolsPath() (src/core/resources.ts) silently falls back to the bundled/configured Pandoc if QUARTO_PANDOC is unset, nonexistent, or otherwise fails to resolve - only a warnOnce, no error. The prior preflight only warned on a version mismatch and continued into writeVariants(), which would then silently regenerate format-extension.ts from the wrong (old, bundled) Pandoc - the exact corruption --skip-archive exists to prevent. Both the unreadable-version and mismatched-version cases now abort instead of warning.
1 parent 429716b commit d7e1e82

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

‎package/src/common/update-pandoc.ts‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { Command } from "cliffy/command/mod.ts";
88
import { join } from "../../../src/deno_ral/path.ts";
99
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";
1111

1212
import {
1313
Configuration,
@@ -72,32 +72,42 @@ export function updatePandoc() {
7272
throw new Error("QUARTO_PANDOC is not set");
7373
}
7474

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;
7883
try {
79-
const reported = lines(
84+
reported = lines(
8085
(await execProcess({
8186
cmd: pandocBinaryPath(),
8287
args: ["--version"],
8388
stdout: "piped",
8489
})).stdout!,
8590
)[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-
}
9591
} 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.",
100109
);
110+
throw new Error("QUARTO_PANDOC does not resolve to the requested version");
101111
}
102112
} else {
103113
// Update the configuration file

0 commit comments

Comments
 (0)