Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

fix(cli): sentry cli uninstall does not detect Homebrew from the Cellar path

Đã đóng Phù hợp với người mới
#1,581 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #1592 của @sentry-junior — đã merge

Đá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 với packages/cli/src/commands/cli/uninstall.ts và phần phát hiện Cellar trong packages/cli/src/lib/upgrade.ts; sau đó xem lại packages/cli/test/commands/cli/uninstall.test.ts cùng bài kiểm tra brew hiện có. Bổ sung kiểm thử cho thông tin cài đặt trống với process.execPath thuộc Cellar. Hoàn thành khi uninstall đề xuất brew uninstall getsentry/tools/sentry và không lên kế hoạch xóa tệp nhị phân của Cellar.

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

Mô tả

Problem

sentry cli uninstall only recognises a Homebrew install if the install method was saved in the CLI database. It checks stored install info (install.method) and detectRuntimePackageManager(), which only looks at node_modules for npm/pnpm/bun/yarn. It never does the Cellar check that sentry cli upgrade uses.

When a Homebrew install has no recorded method, uninstall treats it as self-managed. It doesn't print Run: brew uninstall getsentry/tools/sentry, and it plans to delete the Cellar binary and remove completions, skills and config itself.

This can happen after any brew install that never recorded a method. The old post_install wrote the record into a temporary HOME that Homebrew then deleted (#1545, #1555), and the new caveat command sentry cli setup --no-modify-path --no-completions doesn't pass --method brew. detectInstallationMethod() returns "brew" from the Cellar check before it reaches the code that saves the detected method, so the record stays empty.

Cause

In packages/cli/src/commands/cli/uninstall.ts:

const installInfo = getInstallInfo();
const pmMethod =
  installInfo?.method && installInfo.method in PM_UNINSTALL_HINTS
    ? installInfo.method
    : detectRuntimePackageManager();

detectRuntimePackageManager() (same file) only checks process.argv[1] for node_modules paths. It doesn't look for /Cellar/ and doesn't call detectInstallationMethod().

The self-delete guard has the same problem:

const isSelfManaged =
  !(installInfo?.method || detectRuntimePackageManager()) ||
  installInfo?.method === "curl" ||
  installInfo?.method === "unknown";

With no install info and no node_modules path, isSelfManaged is true for a Homebrew install, so the binary is added to the removal plan.

The Cellar check already exists in packages/cli/src/lib/upgrade.ts, but it's private:

function isHomebrewInstall(): boolean {
  let execPath = process.execPath;
  try { execPath = realpathSync(execPath); } catch { /* use original */ }
  return execPath.includes("/Cellar/");
}

Impact

  • A Homebrew user with no recorded method gets the wrong guidance, and the uninstall plan includes deleting /opt/homebrew/Cellar/sentry/<version>/bin/sentry directly. Homebrew still thinks the package is installed, which can break later brew upgrade or brew uninstall runs.
  • sentry cli upgrade and sentry cli uninstall disagree about how the CLI was installed.
  • The only brew test passes install info explicitly, so CI doesn't cover this path.

Evidence

  • packages/cli/src/commands/cli/uninstall.ts: pmMethod (~lines 457-461), isSelfManaged (~lines 272-276), detectRuntimePackageManager() (~line 67).
  • packages/cli/src/lib/upgrade.ts: isHomebrewInstall() (~lines 355-363, not exported), detectInstallationMethod() (~lines 453-459).
  • packages/cli/test/commands/cli/uninstall.test.ts: the "detects brew install and suggests brew uninstall" test calls setInstallInfo({ method: "brew", ... }). Nothing covers empty install info with a Cellar execPath.
  • Related: #1545, #1555.

Possible fixes

  • Move isHomebrewInstall() into a shared module, e.g. packages/cli/src/lib/binary.ts, and use it first in uninstall.ts for both pmMethod and isSelfManaged. It's a realpathSync plus a substring check, no subprocesses.
  • Don't call detectInstallationMethod() from uninstall: it runs legacy subprocess detection and writes install info, which uninstall shouldn't trigger.
  • Add a test with empty install info and a Cellar process.execPath (mock realpathSync) that asserts the brew uninstall getsentry/tools/sentry hint and that no binary-deletion artifact is produced.
  • We could also add --method brew back to the caveat and docs snippet in #1555. That fixes the immediate case but not the general one.
Ngôn ngữ chính
TypeScript
Star
938
Fork
166
Merge trung bình
1 ngày 7 giờ
Pull request đã merge (30 ngày)
156

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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.

Issue khác của getsentry/toolkit

Tất cả issue của getsentry/toolkit

Issue tương tự

Thêm issue về TypeScript

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.