Skip to content

Commit f9b9f7d

Browse files
authored
Merge pull request #12215 from quarto-dev/backport/julia/escape-windows
Backport Julia escaping fix for Powershell
2 parents 1a6c32c + 256a578 commit f9b9f7d

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

news/changelog-1.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## In this release
44

55
- ([#12147](https://github.com/quarto-dev/quarto-cli/issues/12147)): `serif` and `simple` themes defaults back to have their heading color (`$presentation-heading-color`) to be the same as the body color (`$body-color`) as in Quarto 1.5.
6+
- ([#11659](https://github.com/quarto-dev/quarto-cli/pull/11659)): Julia engine: Fix escaping bug where paths containing spaces or backslashes break server startup on Windows.
67

78
## In previous releases
89

src/execute/julia.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
} from "../config/format.ts";
3535
import { resourcePath } from "../core/resources.ts";
3636
import { quartoRuntimeDir } from "../core/appdirs.ts";
37-
import { normalizePath } from "../core/path.ts";
37+
import { normalizePath, pathWithForwardSlashes } from "../core/path.ts";
3838
import { isInteractiveSession } from "../core/platform.ts";
3939
import { runningInCI } from "../core/ci-info.ts";
4040
import { sleep } from "../core/async.ts";
@@ -248,6 +248,12 @@ export const juliaEngine: ExecutionEngine = {
248248
},
249249
};
250250

251+
function powershell_argument_list_to_string(...args: string[]): string {
252+
// formats as '"arg 1" "arg 2" "arg 3"'
253+
const inner = args.map((arg) => `"${arg}"`).join(" ");
254+
return `'${inner}'`;
255+
}
256+
251257
async function startOrReuseJuliaServer(
252258
options: JuliaExecuteOptions,
253259
): Promise<{ reused: boolean }> {
@@ -265,6 +271,7 @@ async function startOrReuseJuliaServer(
265271
await ensureQuartoNotebookRunnerEnvironment(options);
266272
juliaProject = juliaRuntimeDir();
267273
} else {
274+
juliaProject = pathWithForwardSlashes(juliaProject);
268275
trace(
269276
options,
270277
`Custom julia project set via QUARTO_JULIA_PROJECT="${juliaProject}". Checking if QuartoNotebookRunner can be loaded.`,
@@ -310,15 +317,12 @@ async function startOrReuseJuliaServer(
310317
"Start-Process",
311318
options.julia_cmd,
312319
"-ArgumentList",
313-
// string array argument list, each element but the last must have a "," element after
314-
"--startup-file=no",
315-
",",
316-
`--project=${juliaProject}`,
317-
",",
318-
resourcePath("julia/quartonotebookrunner.jl"),
319-
",",
320-
transportFile,
321-
// end of string array
320+
powershell_argument_list_to_string(
321+
"--startup-file=no",
322+
`--project=${juliaProject}`,
323+
resourcePath("julia/quartonotebookrunner.jl"),
324+
transportFile,
325+
),
322326
"-WindowStyle",
323327
"Hidden",
324328
],

0 commit comments

Comments
 (0)