@@ -70,6 +70,23 @@ export async function checkRBinary() {
7070 }
7171}
7272
73+ function checkWindowsArmR ( platform : string | undefined ) : void {
74+ if ( ! platform ) return ;
75+
76+ const isWindowsArm = isWindows && Deno . build . arch === "aarch64" ;
77+ const isX64R = platform . includes ( "x86_64" ) || platform . includes ( "i386" ) ;
78+
79+ if ( isWindowsArm && isX64R ) {
80+ throw new Error (
81+ "x64 R detected on Windows ARM.\n\n" +
82+ "x64 R runs under emulation and is not reliable for Quarto.\n" +
83+ "Please install native ARM64 R. \n" +
84+ "Read about R on 64-bit Windows ARM at https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" +
85+ "After installation, set QUARTO_R environment variable if the correct version is not correctly found." ,
86+ ) ;
87+ }
88+ }
89+
7390export async function knitrCapabilities ( rBin : string | undefined ) {
7491 if ( ! rBin ) return undefined ;
7592 try {
@@ -108,24 +125,7 @@ export async function knitrCapabilities(rBin: string | undefined) {
108125 )
109126 : false ;
110127
111- // Check for x64 R on Windows ARM even when capabilities check succeeds
112- // x64 R under emulation is intermittently unstable and will crash unpredictably
113- if ( caps . platform ) {
114- const isWindowsArm = isWindows && Deno . build . arch === "aarch64" ;
115- const isX64R = caps . platform . includes ( "x86_64" ) ||
116- caps . platform . includes ( "i386" ) ;
117-
118- if ( isWindowsArm && isX64R ) {
119- throw new Error (
120- "x64 R detected on Windows ARM.\n\n" +
121- "x64 R runs under emulation and is not reliable for Quarto.\n" +
122- "Please install native ARM64 R. \n" +
123- "Read about R on 64-bit Windows ARM at https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" +
124- "After installation, set QUARTO_R environment variable if the correct version is not correctly found." ,
125- ) ;
126- }
127- }
128-
128+ checkWindowsArmR ( caps . platform ) ;
129129 return caps ;
130130 } else {
131131 debug ( "\n++ Problem with results of knitr capabilities check." ) ;
@@ -146,22 +146,7 @@ export async function knitrCapabilities(rBin: string | undefined) {
146146 if ( yamlMatch ) {
147147 const yamlLines = yamlMatch [ 1 ] ;
148148 const caps = readYamlFromString ( yamlLines ) as KnitrCapabilities ;
149-
150- if ( caps . platform ) {
151- const isWindowsArm = isWindows && Deno . build . arch === "aarch64" ;
152- const isX64R = caps . platform . includes ( "x86_64" ) ||
153- caps . platform . includes ( "i386" ) ;
154-
155- if ( isWindowsArm && isX64R ) {
156- throw new Error (
157- "x64 R detected on Windows ARM.\n\n" +
158- "x64 R runs under emulation and is not reliable for Quarto.\n" +
159- "Please install native ARM64 R. \n" +
160- "Read about R on 64-bit Windows ARM at https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/\n" +
161- "After installation, set QUARTO_R environment variable if the correct version is not correctly found." ,
162- ) ;
163- }
164- }
149+ checkWindowsArmR ( caps . platform ) ;
165150 }
166151 } catch ( e ) {
167152 // If it's our specific x64-on-ARM error, rethrow it
@@ -175,7 +160,11 @@ export async function knitrCapabilities(rBin: string | undefined) {
175160
176161 return undefined ;
177162 }
178- } catch {
163+ } catch ( e ) {
164+ // Rethrow x64-on-ARM errors - these have helpful messages
165+ if ( e instanceof Error && e . message . includes ( "x64 R detected" ) ) {
166+ throw e ;
167+ }
179168 debug (
180169 `\n++ Error while running 'capabilities/knitr.R' ${
181170 rBin ? "with " + rBin : ""
@@ -198,17 +187,6 @@ export function knitrCapabilitiesMessage(caps: KnitrCapabilities, indent = "") {
198187 // Show platform information if available
199188 if ( caps . platform ) {
200189 lines . push ( `Platform: ${ caps . platform } ` ) ;
201-
202- // Check for x64 R on Windows ARM and show warning
203- const isWindowsArm = isWindows && Deno . build . arch === "aarch64" ;
204- const isX64R = caps . platform . includes ( "x86_64" ) ||
205- caps . platform . includes ( "i386" ) ;
206- if ( isWindowsArm && isX64R ) {
207- lines . push ( `⚠️ WARNING: x64 R on Windows ARM is not supported` ) ;
208- lines . push (
209- ` Install ARM64 R: https://www.r-project.org/nosvn/winutf8/aarch64/R-4-signed/` ,
210- ) ;
211- }
212190 }
213191
214192 lines . push ( `knitr: ${ caps . packages . knitr || "(None)" } ` ) ;
0 commit comments