Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/services/serveManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,16 @@ export async function spawnServe(
console.log(`[opencode] Spawning: ${command} ${args.join(" ")}`);
console.log(`[opencode] Working directory: ${projectPath}`);

const child = spawn(command, args, {
// Windows: wrap command in quotes when it contains spaces (shell:true path splitting issue)
const windowsCmd = process.platform === "win32" && command.includes(" ")
? `"${command}"`
: command;

const child = spawn(windowsCmd, args, {
cwd: projectPath,
env,
stdio: ["inherit", "pipe", "pipe"],
shell: true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling shell: true unconditionally makes this fix platform-wide. The Windows command is quoted above, but POSIX paths returned by resolveOpencodeCommand are now passed through /bin/sh unquoted and can still be split if they contain spaces. Please keep direct spawn(command, args, ...) behavior on POSIX and only enable shell mode for Windows, with a regression test for a Windows command path containing spaces.

});

const instance: ServeInstance = {
Expand Down