From a0daf8a66871a40657475f3aae4a04f29bd23d33 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 4 Nov 2026 13:26:17 +0100 Subject: [PATCH 1/3] Fix bundled quarto.cmd when the install path contains a space The Windows installers ship quarto.cmd next to quarto.exe. Called from an install path containing a space, its bundled branch failed: the launch line passed the Deno executable and quarto.js unquoted. cmd still found deno.exe, but Deno re-parsed the raw command line and took the rest of its own path as the script, failing with "Permission flags have likely been incorrectly set after the script argument". quarto.exe was not affected. - Quote the Deno executable and quarto.js on the bundled launch line, as the dev launch line already does. - Drop the bundled QUARTO_IMPORT_MAP_ARG. It has not been passed to Deno since the .cmd was aligned with the POSIX quarto script, whose bundled branch sets no import map, and quarto.exe passes none either: quarto.js is a self-contained bundle. - Add a Windows-only test that builds a minimal bundled layout under a directory with a space and checks that quarto.cmd runs quarto.js with its arguments. Follows #15276, which fixed the dev branch. --- package/scripts/windows/quarto.cmd | 3 +- .../bundled-launcher-path-with-space.test.ts | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 tests/unit/bundled-launcher-path-with-space.test.ts diff --git a/package/scripts/windows/quarto.cmd b/package/scripts/windows/quarto.cmd index 6183f4b00aa..a426f70b9a4 100644 --- a/package/scripts/windows/quarto.cmd +++ b/package/scripts/windows/quarto.cmd @@ -109,7 +109,6 @@ IF EXIST "!QUARTO_TS_PATH!" ( SET QUARTO_ACTION=run SET "QUARTO_TARGET=%SCRIPT_PATH%\quarto.js" SET "QUARTO_BIN_PATH=%SCRIPT_PATH%" - SET "QUARTO_IMPORT_MAP_ARG=--importmap=""%SCRIPT_PATH%\vendor\import_map.json""" SET QUARTO_CACHE_OPTIONS=--cached-only ) @@ -174,7 +173,7 @@ IF DEFINED QUARTO_TS_PROFILE ( IF DEFINED QUARTO_DEV_MODE ( "!QUARTO_DENO!" !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! !QUARTO_IMPORT_MAP_ARG! "!QUARTO_TARGET!" %* ) ELSE ( - !QUARTO_DENO! !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! !QUARTO_TARGET! %* + "!QUARTO_DENO!" !QUARTO_ACTION! !QUARTO_CACHE_OPTIONS! !QUARTO_DENO_OPTIONS! !QUARTO_DENO_EXTRA_OPTIONS! "!QUARTO_TARGET!" %* ) diff --git a/tests/unit/bundled-launcher-path-with-space.test.ts b/tests/unit/bundled-launcher-path-with-space.test.ts new file mode 100644 index 00000000000..1ee7dc3bb1f --- /dev/null +++ b/tests/unit/bundled-launcher-path-with-space.test.ts @@ -0,0 +1,81 @@ +/* + * bundled-launcher-path-with-space.test.ts + * + * The bundled launcher bin/quarto.cmd, which the Windows installers ship next + * to quarto.exe, must work when the install path contains a space. + * + * Copyright (C) 2026 Posit Software, PBC + */ + +import { unitTest } from "../test.ts"; +import { assert, assertEquals } from "../asserts.ts"; +import { isWindows } from "../../src/deno_ral/platform.ts"; +import { dirname, fromFileUrl, join } from "../../src/deno_ral/path.ts"; +import { + copySync, + ensureDirSync, + removeSync, + writeTextFileSync, +} from "../../src/deno_ral/fs.ts"; +import { execProcess } from "../../src/core/process.ts"; +import { withTempDir } from "../utils.ts"; + +const repoRoot = join(dirname(fromFileUrl(import.meta.url)), "..", ".."); + +unitTest( + "bundled-launcher - quarto.cmd runs from an install path containing a space", + async () => { + await withTempDir(async (dir) => { + // Minimal bundled install layout: bin/quarto.cmd and bin/quarto.js, + // with no src/quarto.ts above it, so the launcher takes its bundled + // branch. bin/tools is a junction to the dev tools for deno.exe. + const bin = join(dir, "q space", "bin"); + ensureDirSync(bin); + copySync( + join(repoRoot, "package", "scripts", "windows", "quarto.cmd"), + join(bin, "quarto.cmd"), + ); + writeTextFileSync( + join(bin, "quarto.js"), + 'console.log("ARGS=" + JSON.stringify(Deno.args));\n', + ); + const tools = join(bin, "tools"); + const mklink = await execProcess({ + cmd: "cmd", + args: [ + "/c", + "mklink", + "/J", + tools, + join(repoRoot, "package", "dist", "bin", "tools"), + ], + stdout: "piped", + stderr: "piped", + }); + assert(mklink.success, `creating the junction failed: ${mklink.stderr}`); + try { + const result = await execProcess({ + cmd: join(bin, "quarto.cmd"), + args: ["check", "some arg"], + cwd: dir, + stdout: "piped", + stderr: "piped", + }); + const stdout = result.stdout ?? ""; + const stderr = result.stderr ?? ""; + const argsLine = stdout.split(/\r?\n/).find((line) => + line.startsWith("ARGS=") + ); + assertEquals( + argsLine, + 'ARGS=["check","some arg"]', + `quarto.cmd did not run quarto.js with its arguments (exit ${result.code})\nstdout:\n${stdout}\nstderr:\n${stderr}`, + ); + } finally { + // Remove the junction itself (not its target) before the temp dir goes. + removeSync(tools); + } + }); + }, + { ignore: !isWindows }, +); From a10954e9865b182a0ed9494394dfb79a7c9c9e71 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 4 Nov 2026 14:24:02 +0100 Subject: [PATCH 2/3] Read stub arguments through node:process in the bundled launcher test The runtime boundary check counts Deno.* occurrences in tests as text, including inside string literals, so the stub quarto.js written by the test raised the tests count by one and would keep the check red. node:process reads the same arguments without a Deno global. --- tests/unit/bundled-launcher-path-with-space.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/bundled-launcher-path-with-space.test.ts b/tests/unit/bundled-launcher-path-with-space.test.ts index 1ee7dc3bb1f..a51e55091fc 100644 --- a/tests/unit/bundled-launcher-path-with-space.test.ts +++ b/tests/unit/bundled-launcher-path-with-space.test.ts @@ -37,7 +37,8 @@ unitTest( ); writeTextFileSync( join(bin, "quarto.js"), - 'console.log("ARGS=" + JSON.stringify(Deno.args));\n', + 'import process from "node:process";\n' + + 'console.log("ARGS=" + JSON.stringify(process.argv.slice(2)));\n', ); const tools = join(bin, "tools"); const mklink = await execProcess({ From b58a9eed234a83c6999dcd58bf01bb5fffa823f7 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 4 Nov 2026 14:46:28 +0100 Subject: [PATCH 3/3] Check the exit code in the bundled launcher test The test only compared the arguments quarto.js printed, so a launcher that printed them and then exited with an error would still pass. --- tests/unit/bundled-launcher-path-with-space.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/bundled-launcher-path-with-space.test.ts b/tests/unit/bundled-launcher-path-with-space.test.ts index a51e55091fc..c38d3a2d886 100644 --- a/tests/unit/bundled-launcher-path-with-space.test.ts +++ b/tests/unit/bundled-launcher-path-with-space.test.ts @@ -67,11 +67,14 @@ unitTest( const argsLine = stdout.split(/\r?\n/).find((line) => line.startsWith("ARGS=") ); + const details = + `(exit ${result.code})\nstdout:\n${stdout}\nstderr:\n${stderr}`; assertEquals( argsLine, 'ARGS=["check","some arg"]', - `quarto.cmd did not run quarto.js with its arguments (exit ${result.code})\nstdout:\n${stdout}\nstderr:\n${stderr}`, + `quarto.cmd did not run quarto.js with its arguments ${details}`, ); + assert(result.success, `quarto.cmd exited with an error ${details}`); } finally { // Remove the junction itself (not its target) before the temp dir goes. removeSync(tools);