@@ -241,23 +241,64 @@ async function startOrReuseJuliaServer(
241
241
info ( "Starting julia control server process. This might take a while..." ) ;
242
242
await ensureQuartoNotebookRunnerEnvironment ( options ) ;
243
243
244
- const command = new Deno . Command ( options . julia_cmd , {
245
- args : [
246
- "--startup-file=no" ,
247
- resourcePath ( "julia/start_quartonotebookrunner_detached.jl" ) ,
248
- options . julia_cmd ,
249
- juliaRuntimeDir ( ) ,
250
- resourcePath ( "julia/quartonotebookrunner.jl" ) ,
251
- transportFile ,
252
- ] ,
253
- } ) ;
254
- trace (
255
- options ,
256
- "Starting detached julia server through julia, once transport file exists, server should be running." ,
257
- ) ;
258
- // unref seems to be needed to let deno exit in the tests after having spawned the julia process
259
- // that creates the detached child process
260
- command . spawn ( ) . unref ( ) ;
244
+ // We need to spawn the julia server in its own process that can outlive quarto.
245
+ // Apparently, `run(detach(cmd))` in julia does not do that reliably on Windows,
246
+ // at least deno never seems to recognize that the spawning julia process has finished,
247
+ // presumably because it waits for the active child process to exit. This makes the
248
+ // tests on windows hang forever if we use the same launching mechanism as for Unix systems.
249
+ // So we utilize powershell instead which can start completely detached processes with
250
+ // the Start-Process commandlet.
251
+ if ( Deno . build . os === "windows" ) {
252
+ const command = new Deno . Command (
253
+ "PowerShell" ,
254
+ {
255
+ args : [
256
+ "-Command" ,
257
+ "Start-Process" ,
258
+ options . julia_cmd ,
259
+ "-ArgumentList" ,
260
+ // string array argument list, each element but the last must have a "," element after
261
+ "--startup-file=no" ,
262
+ "," ,
263
+ `--project=${ juliaRuntimeDir ( ) } ` ,
264
+ "," ,
265
+ resourcePath ( "julia/quartonotebookrunner.jl" ) ,
266
+ "," ,
267
+ transportFile ,
268
+ // end of string array
269
+ "-WindowStyle" ,
270
+ "Hidden" ,
271
+ ] ,
272
+ } ,
273
+ ) ;
274
+ trace (
275
+ options ,
276
+ "Starting detached julia server through powershell, once transport file exists, server should be running." ,
277
+ ) ;
278
+ const result = command . outputSync ( ) ;
279
+ if ( ! result . success ) {
280
+ throw new Error ( new TextDecoder ( ) . decode ( result . stderr ) ) ;
281
+ }
282
+ } else {
283
+ const command = new Deno . Command ( options . julia_cmd , {
284
+ args : [
285
+ "--startup-file=no" ,
286
+ resourcePath ( "julia/start_quartonotebookrunner_detached.jl" ) ,
287
+ options . julia_cmd ,
288
+ juliaRuntimeDir ( ) ,
289
+ resourcePath ( "julia/quartonotebookrunner.jl" ) ,
290
+ transportFile ,
291
+ ] ,
292
+ } ) ;
293
+ trace (
294
+ options ,
295
+ "Starting detached julia server through julia, once transport file exists, server should be running." ,
296
+ ) ;
297
+ const result = command . outputSync ( ) ;
298
+ if ( ! result . success ) {
299
+ throw new Error ( new TextDecoder ( ) . decode ( result . stderr ) ) ;
300
+ }
301
+ }
261
302
} else {
262
303
trace (
263
304
options ,
0 commit comments