Skip to content

Commit 3d32aed

Browse files
authored
Fix Windows ARM diagnostics for x64 R crashes (#14921)
* fix(R): update Windows ARM installation guidance * fix(R): preserve Windows ARM diagnostics in callers * fix(R): avoid extra ARM diagnostic log metadata
1 parent e24bcbd commit 3d32aed

5 files changed

Lines changed: 416 additions & 179 deletions

File tree

‎news/changelog-1.11.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ All changes included in 1.11:
22

33
## Regression fixes
44

5+
- ([#14920](https://github.com/quarto-dev/quarto-cli/issues/14920)): Fix Windows ARM diagnostics for x64 R crashes to preserve the specialized error in `quarto check`, JSON output, and render failures, and update the native ARM64 R installation guidance.
56
- ([#14731](https://github.com/quarto-dev/quarto-cli/pull/14731)): Fix `QUARTO_VENDOR_BINARIES=false` builds silently succeeding with missing binaries. The `configure` step's "is it on PATH?" check for `typst-gather`, `typst`, `pandoc` and `esbuild` compared an unawaited `Promise` against `undefined`, so the guard never fired. A build with `typst-gather` neither vendored nor on PATH reported success and produced a Quarto tree without it, surfacing only at render time as `typst-gather analyze failed; staging all packages as fallback`. The missing-binary error message now also names the path that was checked and the `QUARTO_TYPST_GATHER` environment variable.
67
- ([#14741](https://github.com/quarto-dev/quarto-cli/issues/14741)): Fix PDF rendering of a cross-referenced table failing with `! Extra }, or forgotten \endgroup.` when the `endfloat` package defers `longtable` environments (`\DeclareDelayedFloatFlavor*{longtable}{table}`).
78
- ([#14857](https://github.com/quarto-dev/quarto-cli/issues/14857)): Fix `quarto install chrome-headless-shell` (and `quarto install chromium`) failing with a 404 on Linux arm64 due to a stale Playwright CDN URL.

‎src/core/knitr.ts‎

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { execProcess } from "./process.ts";
1010
import { rBinaryPath, resourcePath } from "./resources.ts";
1111
import { readYamlFromString } from "./yaml.ts";
1212
import { coerce, satisfies } from "semver/mod.ts";
13-
import { debug } from "../deno_ral/log.ts";
14-
import { errorOnce } from "./log.ts";
13+
import { debug, error } from "../deno_ral/log.ts";
1514

1615
export interface KnitrCapabilities {
1716
versionMajor: number;
@@ -70,32 +69,55 @@ export async function checkRBinary() {
7069
}
7170

7271
export class WindowsArmX64RError extends Error {
73-
constructor(msg: string) {
74-
super(msg);
72+
readonly diagnosticLines: readonly string[];
73+
74+
constructor(readonly exitCode: number) {
75+
const diagnosticLines = [
76+
`R process crashed with known error code (${exitCode}).\n`,
77+
"This typically indicates x64 R running on Windows 11 ARM.",
78+
"x64 R runs under emulation and is not reliable for Quarto.\n",
79+
"To fix this issue:",
80+
'1. Check your R version with: Rscript -e "R.version$platform"',
81+
"2. If it shows 'x86_64-w64-mingw32', install native ARM64 R:",
82+
" https://contributor.r-project.org/windows-arm64/",
83+
"3. Reinstall your R packages using the native ARM64 version of R.",
84+
"4. If needed, set QUARTO_R to the path of the ARM64 Rscript executable.\n",
85+
"Track RStudio compatibility with native ARM64 R here:",
86+
"https://github.com/rstudio/rstudio/issues/15277\n",
87+
"More context on this issue:",
88+
"https://github.com/quarto-dev/quarto-cli/issues/8730",
89+
];
90+
super(diagnosticLines.join("\n"));
91+
this.name = "WindowsArmX64RError";
92+
this.diagnosticLines = diagnosticLines;
7593
}
7694
}
7795

96+
const reportedWindowsArmX64RErrors = new Set<string>();
97+
98+
export function reportWindowsArmX64RError(
99+
armError: WindowsArmX64RError,
100+
errorImpl: (message: string) => void = error,
101+
): boolean {
102+
if (reportedWindowsArmX64RErrors.has(armError.message)) {
103+
return false;
104+
}
105+
106+
reportedWindowsArmX64RErrors.add(armError.message);
107+
armError.diagnosticLines.forEach((line) => errorImpl(line));
108+
return true;
109+
}
110+
78111
// Check for x64 R crashes on ARM Windows
79112
// These specific error codes only occur when x64 R crashes on ARM Windows
80113
// See: https://github.com/quarto-dev/quarto-cli/issues/8730
81114
// https://github.com/cderv/quarto-windows-arm
82-
function throwIfX64ROnArm(exitCode: number): void {
83-
const isX64RCrashOnArm =
84-
exitCode === -1073741569 || // STATUS_NOT_SUPPORTED (native ARM hardware)
85-
exitCode === -1073741819; // STATUS_ACCESS_VIOLATION (Windows ARM VM on Mac)
115+
export function throwIfX64ROnArm(exitCode: number): void {
116+
const isX64RCrashOnArm = exitCode === -1073741569 || // STATUS_NOT_SUPPORTED (native ARM hardware)
117+
exitCode === -1073741819; // STATUS_ACCESS_VIOLATION (Windows ARM VM on Mac)
86118

87119
if (isX64RCrashOnArm) {
88-
throw new WindowsArmX64RError(
89-
`R process crashed with known error code (${exitCode}).\n\n` +
90-
"This typically indicates x64 R running on Windows 11 ARM.\n" +
91-
"x64 R runs under emulation and is not reliable for Quarto.\n\n" +
92-
"To fix this issue:\n" +
93-
"1. Check your R version with: Rscript -e \"R.version$platform\"\n" +
94-
"2. If it shows 'x86_64-w64-mingw32', you need ARM64 R\n" +
95-
"3. Install native ARM64 R: https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" +
96-
"4. If needed, set QUARTO_R environment variable to point to ARM64 Rscript\n\n" +
97-
"More context on this issue: https://github.com/quarto-dev/quarto-cli/issues/8730",
98-
);
120+
throw new WindowsArmX64RError(exitCode);
99121
}
100122
}
101123

@@ -152,10 +174,8 @@ export async function knitrCapabilities(rBin: string | undefined) {
152174
return undefined;
153175
}
154176
} catch (e) {
155-
// Log x64-on-ARM errors once, then return undefined like other errors
156177
if (e instanceof WindowsArmX64RError) {
157-
errorOnce(e.message);
158-
return undefined;
178+
throw e;
159179
}
160180
debug(
161181
`\n++ Error while running 'capabilities/knitr.R' ${

0 commit comments

Comments
 (0)