cli: upgrade cannot detect npm installs on Windows (spawns .cmd shims without a shell)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 74/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- cli
Línea de trabajo
Empieza leyendo el código de detección del método de instalación que inicia npm, pnpm, bun, yarn y vp, y luego compáralo con postinstall.mjs, que según el issue ya gestiona los shims de npm en Windows. Comprueba si la ruta de instalación tiene el mismo comportamiento al iniciar procesos. La tarea estará completa cuando se detecte una instalación global de npm y se actualice en Windows sin --method; verifícalo con los pasos de reproducción del issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
opencode upgrade / update on Windows always fails with "Could not detect the installation method" for npm-based installs, because install-method detection spawns npm/pnpm/yarn without a shell, and Windows cannot launch .cmd shims that way. --method npm bypasses detection, but the detection bug remains.
Environment
- opencode version: 2.1.1 (also reproduced on 2.0.32 and 2.1.0)
- OS: Microsoft Windows [Version 10.0.26200.9457] (Windows 11 25H2, x64)
- Terminal: xterm-256color via agent harness; also fails headless (
opencode update --print-logs) - Shell: C:\WINDOWS\system32\cmd.exe
- Install/channel: release,
npm install -g @opencode/cli(global prefix under the user profile) - Active plugins: none found in config
Reproduction
- On Windows,
npm install -g @opencode/cli. - Run
opencode update(oropencode upgrade). - Detection tries npm/pnpm/bun/yarn/vp and reports "Could not detect the installation method."
Minimal proof the spawn mode is the cause (healthy minimal PATH where where npm succeeds):
subprocess.run(['npm','--version'], shell=False)-> FileNotFoundError / WinError 2.subprocess.run('npm --version', shell=True)->11.12.1.
(bun, a real .exe, spawns fine but correctly reports "not installed via bun".)
Expected Behavior
Detection recognizes the global npm install and upgrades it without requiring --method.
Actual Behavior
Could not detect the installation method. Pass --method to choose how to upgrade OpenCode.
The debug log shows spawning process command=npm args=["list","-g","--depth=0","@opencode/cli"] failing, because npm resolves to npm.cmd, which CreateProcess cannot launch directly (it only resolves .exe).
Additional Context
- Consistently reproducible (2.0.32, 2.1.0, 2.1.1).
- The project's own
postinstall.mjsalready documents this: "Windows cannot spawn npm's .cmd shim directly, so reuse the npm CLI that runs this script" via[process.execPath, process.env.npm_execpath]. Detection needs the same treatment (shell on win32, or resolvenpm.cmdthrough ComSpec). - Workaround:
opencode upgrade --method npmbypasses detection. Note the install step DOES use a shell (its failures surface cmd.exe's "not recognized" error), so--methodworks as long as the user's PATH is healthy; it fails only when PATH itself is broken (separate local issue on my machine: an over-long PATH). - Suggested fix: spawn package managers with a shell on Windows in both the detection and install paths, or invoke
<mgr>.cmdvia ComSpec.
- Lenguaje dominante
- TypeScript
- Estrellas
- 215k
- Forks
- 28.9k
- Merge medio
- 8 h 11 min
- PR fusionados (30 d)
- 365
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de anomalyco/opencode
-
reproduced
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
anomalyco/opencode#57711 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
anomalyco/opencode#57698 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
pending close triaging
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
anomalyco/opencode#57664 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
anomalyco/opencode#57536 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
fs: /cd and file pickers fail on FreeBSD/ZFS — `stat` throws "dev exceeds the safe integer range" (fixed in @effect/platform-node-shared 4.0.5)Posiblemente ocupada @argszero la tomó hace 1 día. Abiertoreproduced
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
anomalyco/opencode#57518 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de anomalyco/opencode
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
chaitin/MonkeyCode#1437 ·
Los mantenedores suelen responder en 1 día
-
rtdb-info-connected-order test: unhandled 'connection is closed' rejection fails the CLI suiteAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
carbon-design-system/carbon-ai-chat#2615 ·
Los mantenedores suelen responder en 1 día
-
e2e-failure ready-to-code
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
redhat-developer/rhdh-plugin-export-overlays#4486 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offlinePosiblemente ocupada @r2jaff la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ComposioHQ/composio#5054 ·
Los mantenedores suelen responder en 1 día