From 4bf5a6bc5c95988d0ee37d1b81576d95efdb009b Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 5 Oct 2026 16:28:58 +0200 Subject: [PATCH] fix(env): detect Windows when its shell garbles the POSIX probe --- packages/env/src/ssh.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/env/src/ssh.ts b/packages/env/src/ssh.ts index 8c9f3b990..9977835df 100644 --- a/packages/env/src/ssh.ts +++ b/packages/env/src/ssh.ts @@ -307,15 +307,14 @@ function termuxWarnings(probe: Probe): string[] { /** Which system the target runs: `uname` through the login shell, or PowerShell on Windows. */ export async function detectPlatform(target: SshTarget): Promise { - let output: string; + let probe: Probe; try { - output = await runSsh(target, POSIX_PROBE); + probe = parseProbe(target, await runSsh(target, POSIX_PROBE)); } catch (error) { - // cmd.exe or PowerShell as the remote shell: no `sh`. - if (!(error instanceof SshError)) throw error; - output = await runSsh(target, WINDOWS_PROBE); + // cmd.exe or PowerShell as the remote shell: no `sh`, or one that gets the probe's quotes wrong. + if (error instanceof HostKeyUnknownError || error instanceof HostKeyChangedError) throw error; + probe = parseProbe(target, await runSsh(target, WINDOWS_PROBE)); } - let probe = parseProbe(target, output); // Git Bash as Windows' default SSH shell: ask PowerShell for Windows' own architecture and home spelling. if (/^(MINGW|MSYS|CYGWIN)/.test(probe.system)) probe = parseProbe(target, await runSsh(target, WINDOWS_PROBE)); const arch = normalizeArch(probe.machine);