From 020c232aaa82ee624c10d81b6485bd1181d8212b Mon Sep 17 00:00:00 2001 From: Sam Clark Date: Thu, 16 Jul 2026 09:57:41 -0500 Subject: [PATCH] fix: quote space-containing args in PowerShell Start-Process on Windows When kernelSupervisor.shutdownTimeout is non-default, Kallichore is launched via PowerShell's Start-Process on Windows. PowerShell joins -ArgumentList array elements with spaces when building the cmd.exe command line, so a path like `c:\Program Files\...\kcserver.exe` is split at the space, causing `'c:\Program' is not recognized` errors. Wrap arguments containing spaces in double-quotes within the PowerShell array so cmd.exe treats them as single tokens. Also change supervisor-wrapper.bat to use %~1 (which strips surrounding double-quotes) when assigning the output file path. Fixes #14671 Co-Authored-By: Claude Sonnet 4.6 --- .../positron-supervisor/resources/supervisor-wrapper.bat | 2 +- .../positron-supervisor/src/KallichoreAdapterApi.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/extensions/positron-supervisor/resources/supervisor-wrapper.bat b/extensions/positron-supervisor/resources/supervisor-wrapper.bat index 3b8d7c02fec6..d1c6fdd71b1c 100644 --- a/extensions/positron-supervisor/resources/supervisor-wrapper.bat +++ b/extensions/positron-supervisor/resources/supervisor-wrapper.bat @@ -18,7 +18,7 @@ if "%~2"=="" ( ) REM The first argument is the output file; consume it. -set output_file=%1 +set "output_file=%~1" shift REM `shift` doesn't affect `%*`, so we have to manually remove the first argument diff --git a/extensions/positron-supervisor/src/KallichoreAdapterApi.ts b/extensions/positron-supervisor/src/KallichoreAdapterApi.ts index 81e49d78a80b..84a63f3277ee 100644 --- a/extensions/positron-supervisor/src/KallichoreAdapterApi.ts +++ b/extensions/positron-supervisor/src/KallichoreAdapterApi.ts @@ -578,7 +578,14 @@ export class KCApi implements PositronSupervisorApi { wrapperPath = 'powershell.exe'; // Build the arguments for the wrapper script const escapedWrapper = kernelWrapper.replace(/'/g, "''"); - const escapedArgs = shellArgs.map(arg => `'${arg.replace(/'/g, "''")}'`).join(', '); + const escapedArgs = shellArgs.map(arg => { + const escapedArg = arg.replace(/'/g, "''"); + // Start-Process joins -ArgumentList elements with spaces when + // building the cmd.exe command line for .bat invocation. Wrap + // args that contain spaces in double-quotes so cmd.exe treats + // them as single tokens. + return arg.includes(' ') ? `'"${escapedArg}"'` : `'${escapedArg}'`; + }).join(', '); shellArgs = [ '-WindowStyle', 'Hidden', '-Command',