From ac4690b24813b999731910b5ec354218b16c141e Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 24 Aug 2026 18:38:15 -0700 Subject: [PATCH] test(startup): pin the platform in the probe-env test shellProbeEnv short-circuits on win32, so the POSIX-only assertion failed for anyone running the suite on Windows. Matches the convention in hydrate-shell-path.windows.test.ts. Also narrows the win32 exemption comment: WindowsShellPathOwnership snapshots its baseline after the seeds land, so it does not unwind them. The exemption holds because Windows keys PATH as `Path` and no Windows seed pins a node version. --- src/main/startup/hydrate-shell-path.test.ts | 4 ++++ src/main/startup/hydrate-shell-path.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/startup/hydrate-shell-path.test.ts b/src/main/startup/hydrate-shell-path.test.ts index 9fc3c96581a..97ac2c3b4cb 100644 --- a/src/main/startup/hydrate-shell-path.test.ts +++ b/src/main/startup/hydrate-shell-path.test.ts @@ -40,6 +40,7 @@ describe('hydrateShellPath', () => { }) afterEach(() => { + vi.restoreAllMocks() if (originalPath === undefined) { delete process.env.PATH } else { @@ -180,6 +181,9 @@ describe('hydrateShellPath', () => { }) it('probes with the recorded launch PATH so seeded fallbacks cannot pin nvm', async () => { + // Why: shellProbeEnv short-circuits on win32, so pin the platform or this + // POSIX-only assertion fails for anyone running the suite on Windows. + vi.spyOn(process, 'platform', 'get').mockReturnValue('darwin') const proc = createMockShellProcess() spawnMock.mockReturnValue(proc) process.env.PATH = `/home/u/.nvm/versions/node/v26.7.0/bin${delimiter}/usr/bin` diff --git a/src/main/startup/hydrate-shell-path.ts b/src/main/startup/hydrate-shell-path.ts index f674d3a49ef..271ace510cf 100644 --- a/src/main/startup/hydrate-shell-path.ts +++ b/src/main/startup/hydrate-shell-path.ts @@ -36,8 +36,8 @@ let probeQueue = Promise.resolve() // ahead of PATH before we probe. nvm's startup `use` honors whatever node is // already on PATH over the user's `default` alias, so a probe that inherits the // seed comes back pinned to that version and every terminal loses the global -// CLIs installed under `default`. Probe with the launch PATH; Windows gets the -// same protection from WindowsShellPathOwnership. +// CLIs installed under `default`. Probe with the launch PATH instead. win32 is +// exempt: it keys PATH as `Path`, and no Windows seed pins a node version. let launchPath: string | null = null let configuredWindowsShell = 'powershell.exe' let configuredWindowsGitBashPath: string | null = null