cli: upgrade cannot detect npm installs on Windows (spawns .cmd shims without a shell)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
Bắt đầu bằng cách đọc mã phát hiện phương thức cài đặt khởi chạy npm, pnpm, bun, yarn và vp, sau đó so sánh với postinstall.mjs, vốn theo issue đã xử lý các shim npm trên Windows. Kiểm tra xem đường dẫn cài đặt có cùng hành vi khởi chạy tiến trình hay không. Hoàn thành khi phát hiện được bản cài đặt npm toàn cục và nâng cấp trên Windows mà không cần --method; hãy xác minh bằng các bước tái hiện của issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 215k
- Fork
- 28.9k
- Merge trung bình
- 8 giờ 11 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anomalyco/opencode
-
reproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
anomalyco/opencode#57711 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
anomalyco/opencode#57698 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
pending close triaging
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
anomalyco/opencode#57664 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
anomalyco/opencode#57536 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
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)Có thể đã có người làm @argszero đã nhận hôm nay. Đang mởreproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
anomalyco/opencode#57518 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của anomalyco/opencode
Issue tương tự
-
[BUG] rag: sentence content can cross the reported sentence boundariesCó thể đã có người làm @LJK-ikun đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URIĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
platformatic/mcp#361 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Push: sem service worker ou sem VAPID, o interruptor de Notificações fica ligado sem avisar nadaĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
melgarafael/DeskcommCRM#3164 ·
Maintainer thường phản hồi trong vòng 1 ngày