Skip to content

fix: resolve spawn EINVAL on Windows for .cmd Pi binary - #3

Open
alexliu072903-bit wants to merge 1 commit into
sigilmakes:mainfrom
alexliu072903-bit:fix/windows-spawn-einval
Open

alexliu072903-bit wants to merge 1 commit into
sigilmakes:mainfrom
alexliu072903-bit:fix/windows-spawn-einval

Conversation

@alexliu072903-bit

Copy link
Copy Markdown

Problem

On Windows, child_process.spawn() cannot directly execute .cmd files without shell: true. When the Pi binary path points to pi.cmd (the standard npm global install on Windows), the plugin throws:

Error: spawn EINVAL

This makes the plugin completely non-functional on Windows out of the box.

Fix

Add shell: process.platform === "win32" to the spawn options in src/rpc.ts:

this.process = spawn(this.piBinaryPath, ["--mode", "rpc", ...this.extraArgs], {
    cwd: this.cwd,
    stdio: ["pipe", "pipe", "pipe"],
    env: { ...process.env },
    shell: process.platform === "win32",
});

This is platform-gated so it only applies on Windows and has no effect on macOS/Linux.

Tested on

  • Windows 11, Node.js 20, Pi binary at C:\Users\<user>\AppData\Roaming\npm\pi.cmd
  • Plugin now connects successfully and streams responses from Pi

Related

Discovered while building obsidian-ai-starter, a setup guide for Pi + Obsidian on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant