CommandCodeAI / CommandCodeAI/command-code

`cmd update` reports success but does not update the installed binary (when installed via bun)

Đang mở
#666 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
4k
Fork
350
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Summary

cmd update prints "✔ Updated to v1.17.0" but cmd --version stays on the old version. No error is shown. The self-updater assumes npm
global install and never touches bun-installed binaries, so the update silently no-ops for bun users.

Expected Behavior
  • cmd update upgrades the binary that is actually on PATH.
  • After update, cmd --version shows the new version.
  • If the binary did not change, the command reports failure (non-zero exit) with manual instructions — never a false success.
  • --check-only behavior is preserved.
Actual Behavior
  • cmd update always runs npm i -g command-code (hardcoded updateCommand in updateAction2runCliUpdateCommand).
  • On a bun install (~/.bun/bin/cmd → bun global node_modules), the new version lands in npm's global dir as an orphan copy (no cmd bin link), while the PATH binary is untouched.
  • Success is reported from the install command's exit code, not from the on-disk version changing.
Steps to reproduce the issue
  1. Install via bun: bun i -g command-code
  2. Run cmd update → prints "✔ Updated to v1.17.0. Run cmd to start using the new version."
  3. Run cmd --version → still old version (e.g. 1.14.0)
  4. Confirm orphan copy: ls /opt/homebrew/lib/node_modules/command-code (npm prefix) vs ls ~/.bun/install/global/node_modules/command-code (bun) — versions differ.
Command Code Version

1.14.0

Operating System

macOS

Terminal/IDE

ghostty

Shell

zsh

Session file (optional)

No response

Fix prompt (optional)

Fix the self-update logic so it updates the binary that is really on PATH:

  1. Detect install method before updating. Inspect the resolved binary path (process.argv[1]; e.g. .bun/install/global/...,
    /opt/homebrew/bin, npx shim) and/or probe package-manager globals for command-code (bun: ~/.bun/install/global, npm: npm root -g,
    brew: brew list).
  2. Update via the matching manager:
    • bun → bun i -g command-code@latest
    • npm → npm i -g command-code@latest
    • brew → brew upgrade command-code (if available)
    • unknown → current behavior + warning.
  3. Verify after update. Compare the version of the resolved install before/after (package.json or --version). Report success only
    if the PATH binary version actually changed.
  4. On stale binary → print failure with manual instructions, exit non-zero.
  5. Keep --check-only semantics; keep telemetry, add install_method field if cheap.

Acceptance criteria:

  • bun install: cmd update upgrades the bun copy; cmd --version shows new version; no orphan npm copy created.
  • npm install: behavior unchanged.
  • Update command succeeds but version unchanged → failure, non-zero exit, manual instructions.
  • Unit tests cover: method detection (bun/npm/brew/path shims), command selection per method, post-update verification (success + stale
    cases).
Additional context

OS: macOS Tahoe 26.5.2

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Theo dõi updateAction2 và runCliUpdateCommand, bắt đầu với updateCommand được hardcode và đường dẫn được phân giải từ process.argv[1]. Sử dụng các trường hợp unit test đã nêu để bao phủ bun, npm, brew và các path shim, sau đó xác minh rằng binary được phân giải thay đổi sau khi cập nhật và các bản cập nhật lỗi thời sẽ thất bại mà không thay đổi hành vi của --check-only.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
bun
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.