You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows ACL sandbox tests fail on hosts without PowerShell 7 (pwsh), test bug + fix
#2912
packages/sandbox/sandbox-windows-acl/tests/runner.spec.ts fails 6 tests on
any Windows host that only has the built-in Windows PowerShell (5.1) β
which is most Windows machines, since PowerShell 7 (pwsh.exe) isn't
preinstalled.
Repro
Clean checkout, Windows 11, Node 22.17, no pwsh.exe on PATH:
pnpm vitest run packages/sandbox/sandbox-windows-acl
The suite gates itself with describe.skipIf(!isWin32 || !pwshAvailable()),
and pwshAvailable() correctly resolves the real executable through resolvePwshPath() β which, per its own doc comment, falls back to the
legacy Windows PowerShell 5.1 binary when pwsh.exe isn't installed. So on
a host with only PowerShell 5.1, the gate passes (a real PowerShell is
available).
But the test bodies then spawn the confined child against a hardcoded 'pwsh' string literal instead of that same resolved path:
CreateProcessAsUserW can't find literal "pwsh" on the confined child's
search path, so the runner fails closed (exit 127) instead of either
skipping or running against the resolved executable.
Worth noting the production code doesn't have this bug β PwshLocalExecutor.argv()
in packages/shell/pwsh-local/src/index.ts already spawns through the
resolved this.pwshPath, never a literal. It's isolated to this one test file.
Fix
Reuse the same resolvePwshPath() result the skip-gate already computes,
everywhere the tests spawn pwsh (7 call sites, 1 file):
--- a/packages/sandbox/sandbox-windows-acl/tests/runner.spec.ts+++ b/packages/sandbox/sandbox-windows-acl/tests/runner.spec.ts@@ -17,12 +17,17 @@ import { AclWriteGrant, tempWriteSid, workspaceWriteSid } from '../src/index.ts'
const isWin32 = process.platform === 'win32'
const runnerEntry = fileURLToPath(new URL('../src/runner.ts', import.meta.url))
+// The same resolution the skip-gate probes and the production executor+// spawns through: a bare 'pwsh' literal is not guaranteed to be on the+// confined child's search path, and legacy hosts carry only the Windows+// PowerShell 5.1 fallback (no pwsh.exe at all).+const pwshPath = resolvePwshPath()
// Functional probe, not where.exe: spawnSync never throws on a missing
// binary (status null) and where.exe exits 1 without pwsh β only an actual
// pwsh invocation's exit status is truth.
function pwshAvailable(): boolean {
- return spawnSync(resolvePwshPath(), ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', '$true'], { encoding: 'utf8' }).status === 0+ return spawnSync(pwshPath, ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', '$true'], { encoding: 'utf8' }).status === 0
}
...and the same '--', 'pwsh', ... β '--', pwshPath, ... swap at the
remaining 6 call sites in the test bodies (lines 97, 129, 158, 187, 350,
363, 390 on master).
Happy to open a PR with the full diff if external PRs are being accepted β
I know CONTRIBUTING.md currently says they're not, so posting here per
that guidance in the meantime.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Summary
packages/sandbox/sandbox-windows-acl/tests/runner.spec.tsfails 6 tests onany Windows host that only has the built-in Windows PowerShell (5.1) β
which is most Windows machines, since PowerShell 7 (
pwsh.exe) isn'tpreinstalled.
Repro
Clean checkout, Windows 11, Node 22.17, no
pwsh.exeonPATH:6 of 14 tests in the file fail this way.
Root cause
The suite gates itself with
describe.skipIf(!isWin32 || !pwshAvailable()),and
pwshAvailable()correctly resolves the real executable throughresolvePwshPath()β which, per its own doc comment, falls back to thelegacy Windows PowerShell 5.1 binary when
pwsh.exeisn't installed. So ona host with only PowerShell 5.1, the gate passes (a real PowerShell is
available).
But the test bodies then spawn the confined child against a hardcoded
'pwsh'string literal instead of that same resolved path:CreateProcessAsUserWcan't find literal"pwsh"on the confined child'ssearch path, so the runner fails closed (exit 127) instead of either
skipping or running against the resolved executable.
Worth noting the production code doesn't have this bug β
PwshLocalExecutor.argv()in
packages/shell/pwsh-local/src/index.tsalready spawns through theresolved
this.pwshPath, never a literal. It's isolated to this one test file.Fix
Reuse the same
resolvePwshPath()result the skip-gate already computes,everywhere the tests spawn
pwsh(7 call sites, 1 file):...and the same
'--', 'pwsh', ...β'--', pwshPath, ...swap at theremaining 6 call sites in the test bodies (lines 97, 129, 158, 187, 350,
363, 390 on
master).Verified
Happy to open a PR with the full diff if external PRs are being accepted β
I know CONTRIBUTING.md currently says they're not, so posting here per
that guidance in the meantime.
All reactions