Skip to content

Commit a22f2a4

Browse files
committed
fix: use platform temp dir for background process output
Use os.tmpdir() instead of hardcoded /tmp/mux-bashes. On Windows, convert to POSIX path using cygpath for Git Bash compatibility. This fixes background process execution on Windows where /tmp doesn't exist or requires elevated privileges.
1 parent b816c1a commit a22f2a4

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/node/runtime/runtimeFactory.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { execSync } from "child_process";
2+
import * as os from "os";
3+
14
import type { Runtime } from "./Runtime";
25
import { LocalRuntime } from "./LocalRuntime";
36
import { WorktreeRuntime } from "./WorktreeRuntime";
@@ -9,8 +12,25 @@ import { isIncompatibleRuntimeConfig } from "@/common/utils/runtimeCompatibility
912
// Re-export for backward compatibility with existing imports
1013
export { isIncompatibleRuntimeConfig };
1114

12-
// Default output directory for background processes
13-
const DEFAULT_BG_OUTPUT_DIR = "/tmp/mux-bashes";
15+
/**
16+
* Get the default output directory for background processes.
17+
* Uses os.tmpdir() for platform-appropriate temp directory.
18+
* On Windows, converts to POSIX path using cygpath for Git Bash compatibility.
19+
*/
20+
function getDefaultBgOutputDir(): string {
21+
const tempDir = os.tmpdir();
22+
if (process.platform === "win32") {
23+
try {
24+
// cygpath converts Windows paths to POSIX format for Git Bash / MSYS2
25+
const posixPath = execSync(`cygpath -u "${tempDir}"`, { encoding: "utf8" }).trim();
26+
return `${posixPath}/mux-bashes`;
27+
} catch {
28+
// Fallback if cygpath unavailable (shouldn't happen with Git Bash)
29+
return "/tmp/mux-bashes";
30+
}
31+
}
32+
return `${tempDir}/mux-bashes`;
33+
}
1434

1535
/**
1636
* Error thrown when a workspace has an incompatible runtime configuration,
@@ -52,7 +72,7 @@ export function createRuntime(config: RuntimeConfig, options?: CreateRuntimeOpti
5272
);
5373
}
5474

55-
const bgOutputDir = config.bgOutputDir ?? DEFAULT_BG_OUTPUT_DIR;
75+
const bgOutputDir = config.bgOutputDir ?? getDefaultBgOutputDir();
5676

5777
switch (config.type) {
5878
case "local":

0 commit comments

Comments
 (0)