Skip to content

Commit cecd6f3

Browse files
authored
Fix bundled quarto.cmd when the install path contains a space (#15288)
The Windows installers ship quarto.cmd next to quarto.exe. Its bundled launch line passed the Deno executable and quarto.js unquoted, so when the install path contained a space, Deno re-parsed the raw command line, took the rest of its own path as the script, and failed before Quarto started. quarto.exe was not affected. - Quote the Deno executable and quarto.js on the bundled launch line, matching the dev launch line. - Remove QUARTO_IMPORT_MAP_ARG from the bundled branch. It has not been passed to Deno since quarto.cmd was aligned with the POSIX quarto script, and quarto.js is a self-contained bundle. - Add a Windows-only test that runs quarto.cmd from a bundled layout under a directory with a space and checks that it runs quarto.js with its arguments. See #15276, which fixed the same problem in the dev branch.
1 parent 6e6fc9b commit cecd6f3

2 files changed

Lines changed: 86 additions & 2 deletions

File tree

‎package/scripts/windows/quarto.cmd‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ IF EXIST "!QUARTO_TS_PATH!" (
106106
SET QUARTO_ACTION=run
107107
SET "QUARTO_TARGET=%SCRIPT_PATH%\quarto.js"
108108
SET "QUARTO_BIN_PATH=%SCRIPT_PATH%"
109-
SET "QUARTO_IMPORT_MAP_ARG=--importmap=""%SCRIPT_PATH%\vendor\import_map.json"""
110109
SET QUARTO_CACHE_OPTIONS=--cached-only
111110
)
112111

@@ -171,7 +170,7 @@ IF DEFINED QUARTO_TS_PROFILE (
171170
IF DEFINED QUARTO_DEV_MODE (
172171
"!QUARTO_DENO!" !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! !QUARTO_IMPORT_MAP_ARG! "!QUARTO_TARGET!" %*
173172
) ELSE (
174-
!QUARTO_DENO! !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! !QUARTO_TARGET! %*
173+
"!QUARTO_DENO!" !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! "!QUARTO_TARGET!" %*
175174
)
176175

177176

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* bundled-launcher-path-with-space.test.ts
3+
*
4+
* The bundled launcher bin/quarto.cmd, which the Windows installers ship next
5+
* to quarto.exe, must work when the install path contains a space.
6+
*
7+
* Copyright (C) 2026 Posit Software, PBC
8+
*/
9+
10+
import { unitTest } from "../test.ts";
11+
import { assert, assertEquals } from "../asserts.ts";
12+
import { isWindows } from "../../src/deno_ral/platform.ts";
13+
import { dirname, fromFileUrl, join } from "../../src/deno_ral/path.ts";
14+
import {
15+
copySync,
16+
ensureDirSync,
17+
removeSync,
18+
writeTextFileSync,
19+
} from "../../src/deno_ral/fs.ts";
20+
import { execProcess } from "../../src/core/process.ts";
21+
import { withTempDir } from "../utils.ts";
22+
23+
const repoRoot = join(dirname(fromFileUrl(import.meta.url)), "..", "..");
24+
25+
unitTest(
26+
"bundled-launcher - quarto.cmd runs from an install path containing a space",
27+
async () => {
28+
await withTempDir(async (dir) => {
29+
// Minimal bundled install layout: bin/quarto.cmd and bin/quarto.js,
30+
// with no src/quarto.ts above it, so the launcher takes its bundled
31+
// branch. bin/tools is a junction to the dev tools for deno.exe.
32+
const bin = join(dir, "q space", "bin");
33+
ensureDirSync(bin);
34+
copySync(
35+
join(repoRoot, "package", "scripts", "windows", "quarto.cmd"),
36+
join(bin, "quarto.cmd"),
37+
);
38+
writeTextFileSync(
39+
join(bin, "quarto.js"),
40+
'import process from "node:process";\n' +
41+
'console.log("ARGS=" + JSON.stringify(process.argv.slice(2)));\n',
42+
);
43+
const tools = join(bin, "tools");
44+
const mklink = await execProcess({
45+
cmd: "cmd",
46+
args: [
47+
"/c",
48+
"mklink",
49+
"/J",
50+
tools,
51+
join(repoRoot, "package", "dist", "bin", "tools"),
52+
],
53+
stdout: "piped",
54+
stderr: "piped",
55+
});
56+
assert(mklink.success, `creating the junction failed: ${mklink.stderr}`);
57+
try {
58+
const result = await execProcess({
59+
cmd: join(bin, "quarto.cmd"),
60+
args: ["check", "some arg"],
61+
cwd: dir,
62+
stdout: "piped",
63+
stderr: "piped",
64+
});
65+
const stdout = result.stdout ?? "";
66+
const stderr = result.stderr ?? "";
67+
const argsLine = stdout.split(/\r?\n/).find((line) =>
68+
line.startsWith("ARGS=")
69+
);
70+
const details =
71+
`(exit ${result.code})\nstdout:\n${stdout}\nstderr:\n${stderr}`;
72+
assertEquals(
73+
argsLine,
74+
'ARGS=["check","some arg"]',
75+
`quarto.cmd did not run quarto.js with its arguments ${details}`,
76+
);
77+
assert(result.success, `quarto.cmd exited with an error ${details}`);
78+
} finally {
79+
// Remove the junction itself (not its target) before the temp dir goes.
80+
removeSync(tools);
81+
}
82+
});
83+
},
84+
{ ignore: !isWindows },
85+
);

0 commit comments

Comments
 (0)