Skip to content
This repository was archived by the owner on Apr 24, 2026. It is now read-only.

Commit ba52e90

Browse files
lanmowerclaude
andcommitted
Fix bash runtime on Windows to use PowerShell instead of cmd.exe
On Windows, exec:bash was writing a .sh file then spawning cmd.exe with the script path — cmd.exe cannot execute .sh files, producing blank output. Now detects IS_WIN + bash runtime, writes a .ps1 file with PowerShell header, and spawns POWERSHELL with -NoProfile -NonInteractive -File flags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent efb5c0c commit ba52e90

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/workers/isolation-worker.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,22 @@ async function executeInProcess(code, runtime, workingDirectory, processTimeout)
114114
try {
115115
const tempDir = mkdtempSync(path.join(os.tmpdir(), 'glootie_'));
116116
activeTempDir = tempDir;
117-
const ext = runtime === 'bash' ? '.sh' : '.bat';
118-
const script = runtime === 'bash'
119-
? `#!/bin/bash\nset -e\n${code}`
120-
: `@echo off\nsetlocal enabledelayedexpansion\n${code}`;
117+
const usePowerShell = IS_WIN && runtime === 'bash';
118+
const ext = runtime === 'cmd' ? '.bat' : usePowerShell ? '.ps1' : '.sh';
119+
const script = runtime === 'cmd'
120+
? `@echo off\nsetlocal enabledelayedexpansion\n${code}`
121+
: usePowerShell
122+
? `$ErrorActionPreference = 'Continue'\n${code}`
123+
: `#!/bin/bash\nset -e\n${code}`;
121124
const scriptFile = path.join(tempDir, `script${ext}`);
122125
writeFileSync(scriptFile, script);
123-
child = spawn(config.command,
124-
runtime === 'cmd' ? ['/c', scriptFile] : [scriptFile],
126+
const spawnCmd = usePowerShell ? POWERSHELL : config.command;
127+
const spawnArgs = runtime === 'cmd'
128+
? ['/c', scriptFile]
129+
: usePowerShell
130+
? ['-NoProfile', '-NonInteractive', '-File', scriptFile]
131+
: [scriptFile];
132+
child = spawn(spawnCmd, spawnArgs,
125133
{ cwd: workingDirectory, stdio: ['ignore', 'pipe', 'pipe'], timeout: processTimeout, detached: false }
126134
);
127135
} catch (e) {

0 commit comments

Comments
 (0)