From fc1124aba7a60c10efa7e7f9232284e58bc5f3a8 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 22 Dec 2025 13:11:20 +0100 Subject: [PATCH 1/6] fix: detect x64 R on Windows ARM via exit codes When x64 R crashes on Windows ARM, detect specific exit codes and provide helpful error message instead of generic "check your R installation". Detects two crash scenarios: - Native ARM hardware: -1073741569 (STATUS_NOT_SUPPORTED) - Windows ARM VM on Mac: -1073741819 (STATUS_ACCESS_VIOLATION) Both occur when rmarkdown package loads under x64 emulation. R script completes successfully and produces YAML before crashing during cleanup. These error codes are unique to x64 R on ARM Windows, so checking them directly is sufficient without needing to verify ARM hardware via Windows API. Closes #8730 Related: #13790 --- src/core/knitr.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/core/knitr.ts b/src/core/knitr.ts index d525c97ea28..13358944bf0 100644 --- a/src/core/knitr.ts +++ b/src/core/knitr.ts @@ -68,6 +68,12 @@ export async function checkRBinary() { } } +export class WindowsArmX64RError extends Error { + constructor(msg: string) { + super(msg); + } +} + export async function knitrCapabilities(rBin: string | undefined) { if (!rBin) return undefined; try { @@ -115,9 +121,30 @@ export async function knitrCapabilities(rBin: string | undefined) { if (result.stderr) { debug(` with stderr from R:\n${result.stderr}`); } + + // Check for x64 R crashes on ARM Windows + // These specific error codes only occur when x64 R crashes on ARM Windows + const isX64RCrashOnArm = + result.code === -1073741569 || // STATUS_NOT_SUPPORTED (native ARM hardware) + result.code === -1073741819; // STATUS_ACCESS_VIOLATION (Windows ARM VM on Mac) + + if (isX64RCrashOnArm) { + throw new WindowsArmX64RError( + "x64 R detected on Windows ARM.\n\n" + + "x64 R runs under emulation and is not reliable for Quarto.\n" + + "Please install native ARM64 R. \n" + + "Read about R on 64-bit Windows ARM at https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" + + "After installation, set QUARTO_R environment variable if the correct version is not correctly found.", + ); + } + return undefined; } - } catch { + } catch (e) { + // Rethrow x64-on-ARM errors - these have helpful messages + if (e instanceof WindowsArmX64RError) { + throw e; + } debug( `\n++ Error while running 'capabilities/knitr.R' ${ rBin ? "with " + rBin : "" From c5219033451f30258b73f3e437aae0198f307486 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 22 Dec 2025 14:06:01 +0100 Subject: [PATCH 2/6] docs: add issue and test repo links to ARM detection comment Add references to issue #8730 and quarto-windows-arm test repository in code comments to help future contributors understand the context. --- src/core/knitr.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/knitr.ts b/src/core/knitr.ts index 13358944bf0..29a03f03679 100644 --- a/src/core/knitr.ts +++ b/src/core/knitr.ts @@ -124,6 +124,8 @@ export async function knitrCapabilities(rBin: string | undefined) { // Check for x64 R crashes on ARM Windows // These specific error codes only occur when x64 R crashes on ARM Windows + // See: https://github.com/quarto-dev/quarto-cli/issues/8730 + // https://github.com/cderv/quarto-windows-arm const isX64RCrashOnArm = result.code === -1073741569 || // STATUS_NOT_SUPPORTED (native ARM hardware) result.code === -1073741819; // STATUS_ACCESS_VIOLATION (Windows ARM VM on Mac) From de23d057bc2d237510b64a1fa949b1bf156c35ef Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 22 Dec 2025 14:09:26 +0100 Subject: [PATCH 3/6] fix: improve Windows ARM x64 R error message Make error message more actionable: - Show detected error code - Explain x64 R on Windows ARM issue - Provide step-by-step fix instructions - Link to issue #8730 for context --- src/core/knitr.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/knitr.ts b/src/core/knitr.ts index 29a03f03679..a71e8f4f9d1 100644 --- a/src/core/knitr.ts +++ b/src/core/knitr.ts @@ -132,11 +132,15 @@ export async function knitrCapabilities(rBin: string | undefined) { if (isX64RCrashOnArm) { throw new WindowsArmX64RError( - "x64 R detected on Windows ARM.\n\n" + - "x64 R runs under emulation and is not reliable for Quarto.\n" + - "Please install native ARM64 R. \n" + - "Read about R on 64-bit Windows ARM at https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" + - "After installation, set QUARTO_R environment variable if the correct version is not correctly found.", + `R process crashed with known error code (${result.code}).\n\n` + + "This typically indicates x64 R running on Windows 11 ARM.\n" + + "x64 R runs under emulation and is not reliable for Quarto.\n\n" + + "To fix this issue:\n" + + "1. Check your R version with: Rscript -e \"R.version$platform\"\n" + + "2. If it shows 'x86_64-w64-mingw32', you need ARM64 R\n" + + "3. Install native ARM64 R: https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" + + "4. If needed, set QUARTO_R environment variable to point to ARM64 Rscript\n\n" + + "More context on this issue: https://github.com/quarto-dev/quarto-cli/issues/8730", ); } From 76dfb9f1579558bab2b6cf34b63f5fe2b69a7c1f Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 22 Dec 2025 15:52:06 +0100 Subject: [PATCH 4/6] fix: prevent duplicate Windows ARM x64 R error message Use errorOnce() instead of rethrowing WindowsArmX64RError to prevent duplicate error messages when printCallRDiagnostics() calls knitrCapabilities() again. Returns undefined like other knitrCapabilities errors without changing general error handling in callR(). --- src/core/knitr.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/knitr.ts b/src/core/knitr.ts index a71e8f4f9d1..10672a9097b 100644 --- a/src/core/knitr.ts +++ b/src/core/knitr.ts @@ -11,6 +11,7 @@ import { rBinaryPath, resourcePath } from "./resources.ts"; import { readYamlFromString } from "./yaml.ts"; import { coerce, satisfies } from "semver/mod.ts"; import { debug } from "../deno_ral/log.ts"; +import { errorOnce } from "./log.ts"; export interface KnitrCapabilities { versionMajor: number; @@ -147,9 +148,10 @@ export async function knitrCapabilities(rBin: string | undefined) { return undefined; } } catch (e) { - // Rethrow x64-on-ARM errors - these have helpful messages + // Log x64-on-ARM errors once, then return undefined like other errors if (e instanceof WindowsArmX64RError) { - throw e; + errorOnce(e.message); + return undefined; } debug( `\n++ Error while running 'capabilities/knitr.R' ${ From ffc5f15eadfb5a51fc1c6ba974d693e41d5de818 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 22 Dec 2025 16:44:25 +0100 Subject: [PATCH 5/6] refactor: extract x64-on-ARM check into throwIfX64ROnArm() Extract x64 R crash detection into helper function for better code organization. Function name clearly indicates it throws on detection. --- src/core/knitr.ts | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/core/knitr.ts b/src/core/knitr.ts index 10672a9097b..478cb1deedc 100644 --- a/src/core/knitr.ts +++ b/src/core/knitr.ts @@ -75,6 +75,30 @@ export class WindowsArmX64RError extends Error { } } +// Check for x64 R crashes on ARM Windows +// These specific error codes only occur when x64 R crashes on ARM Windows +// See: https://github.com/quarto-dev/quarto-cli/issues/8730 +// https://github.com/cderv/quarto-windows-arm +function throwIfX64ROnArm(exitCode: number): void { + const isX64RCrashOnArm = + exitCode === -1073741569 || // STATUS_NOT_SUPPORTED (native ARM hardware) + exitCode === -1073741819; // STATUS_ACCESS_VIOLATION (Windows ARM VM on Mac) + + if (isX64RCrashOnArm) { + throw new WindowsArmX64RError( + `R process crashed with known error code (${exitCode}).\n\n` + + "This typically indicates x64 R running on Windows 11 ARM.\n" + + "x64 R runs under emulation and is not reliable for Quarto.\n\n" + + "To fix this issue:\n" + + "1. Check your R version with: Rscript -e \"R.version$platform\"\n" + + "2. If it shows 'x86_64-w64-mingw32', you need ARM64 R\n" + + "3. Install native ARM64 R: https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" + + "4. If needed, set QUARTO_R environment variable to point to ARM64 Rscript\n\n" + + "More context on this issue: https://github.com/quarto-dev/quarto-cli/issues/8730", + ); + } +} + export async function knitrCapabilities(rBin: string | undefined) { if (!rBin) return undefined; try { @@ -123,27 +147,7 @@ export async function knitrCapabilities(rBin: string | undefined) { debug(` with stderr from R:\n${result.stderr}`); } - // Check for x64 R crashes on ARM Windows - // These specific error codes only occur when x64 R crashes on ARM Windows - // See: https://github.com/quarto-dev/quarto-cli/issues/8730 - // https://github.com/cderv/quarto-windows-arm - const isX64RCrashOnArm = - result.code === -1073741569 || // STATUS_NOT_SUPPORTED (native ARM hardware) - result.code === -1073741819; // STATUS_ACCESS_VIOLATION (Windows ARM VM on Mac) - - if (isX64RCrashOnArm) { - throw new WindowsArmX64RError( - `R process crashed with known error code (${result.code}).\n\n` + - "This typically indicates x64 R running on Windows 11 ARM.\n" + - "x64 R runs under emulation and is not reliable for Quarto.\n\n" + - "To fix this issue:\n" + - "1. Check your R version with: Rscript -e \"R.version$platform\"\n" + - "2. If it shows 'x86_64-w64-mingw32', you need ARM64 R\n" + - "3. Install native ARM64 R: https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" + - "4. If needed, set QUARTO_R environment variable to point to ARM64 Rscript\n\n" + - "More context on this issue: https://github.com/quarto-dev/quarto-cli/issues/8730", - ); - } + throwIfX64ROnArm(result.code); return undefined; } From 07470f5e77a83983b15ae426d292e7c49c47f57a Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Mon, 22 Dec 2025 17:06:59 +0100 Subject: [PATCH 6/6] docs: add changelog entry for Windows ARM x64 R detection --- news/changelog-1.9.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index fc729be0e8d..d32a54009d3 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -94,3 +94,4 @@ All changes included in 1.9: - ([#13528](https://github.com/quarto-dev/quarto-cli/pull/13528)): Adds support for table specification using nested lists and the `list-table` class. - ([#13575](https://github.com/quarto-dev/quarto-cli/pull/13575)): Improve CPU architecture detection/reporting in macOS to allow quarto to run in virtualized environments such as OpenAI's `codex`. - ([#13656](https://github.com/quarto-dev/quarto-cli/issues/13656)): Fix R code cells with empty `lang: ""` option producing invalid markdown class attributes. +- ([#8730](https://github.com/quarto-dev/quarto-cli/issues/8730)): Detect x64 R crashes on Windows ARM and provide helpful error message directing users to install native ARM64 R instead of showing generic "check your R installation" error.