Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

setup-learning.ts fails on Windows with "spawn npx.cmd EINVAL"

Aperta Adatta ai principianti
#792 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Caldas ci sta già lavorando.

Dal 14/10/2026.

  • #793 di @Caldas — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
80/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nodejs, typescript
Ambito
backend, cli

Direzione di ricerca

Inizia da runCli in server/src/learning/ensure-container.ts (intorno alle righe 124-149), dove spawn viene chiamato senza shell su Windows, e segui il punto di ingresso da scripts/setup-learning.ts. Riproduci su Windows con bun scripts/setup-learning.ts per vedere l'EINVAL, e verifica che il gestore child.on("error") venga bypassato. Completato quando lo script di setup viene eseguito su Windows e i comandi CLI hanno successo, con il comportamento su macOS e Linux invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

On Windows, bun scripts/setup-learning.ts (Quick start, step 2) stops before doing anything, and prints only this:

PS C:\...\openbot> bun scripts/setup-learning.ts
spawn npx.cmd EINVAL

npx --yes copilotkit@latest login and project select had both succeeded beforehand, from the OpenBot root. Nothing is written to .env, so neither the runtime key nor the openbot Learning container is set up.

Cause

runCli in server/src/learning/ensure-container.ts:124-149 starts the CopilotKit CLI like this:

const child = spawn(
  process.platform === "win32" ? "npx.cmd" : "npx",
  ["--yes", "copilotkit@latest", ...args],
  { cwd: directory, env: cliEnvironment(), stdio: ["ignore", "pipe", "pipe"] },
);

Since the fix for CVE-2024-27980, Node refuses to spawn a .cmd or .bat file without shell: true, and Bun does the same. The refusal is a synchronous EINVAL thrown by spawn() itself, not an 'error' event. As a result, the child.on("error", () => finish(127)) handler at line 147 never runs. The throw happens inside the Promise executor, so it becomes a rejection, and setup-learning.ts exits with the bare message.

Minimal reproduction, Bun 1.4.3 on Windows 11:

import { spawn } from "node:child_process";
spawn("npx.cmd", ["--version"]);                 // throws: spawn npx.cmd EINVAL
spawn("npx.cmd", ["--version"], { shell: true }); // runs, prints 11.19.0

The server calls the same runCli from ensureLearningContainer at boot (server/src/index.ts:360) when a CLI login is present. Automatic container creation should therefore fail the same way on Windows, although I have only reproduced it through the setup helper.

Suggested fix

Run through the shell on Windows only:

{
  cwd: directory,
  env: cliEnvironment(),
  shell: process.platform === "win32",
  stdio: ["ignore", "pipe", "pipe"],
}

With shell: true the arguments are joined into a cmd.exe command line rather than passed as an argv. That is safe here because every caller passes literals (whoami, project list --json). cliEnvironment() already keeps COMSPEC, SystemRoot and PATHEXT, so cmd.exe resolves. macOS and Linux are unchanged.

Windows 11 Enterprise 10.0.26200, Bun 1.4.3, Node 24.21.0 / npm 11.19.0, OpenBot at 8c9ad4c. Related: #679 and #681 (other Windows checkout problems).

Lingua principale
TypeScript
Stelle
6.3k
Fork
863
Merge medio
17h 38m
PR unite (30g)
161

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CopilotKit/OpenBot

Tutte le issue di CopilotKit/OpenBot

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.