fix(cli): sentry cli uninstall does not detect Homebrew from the Cellar path
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/sentrydirectly. Homebrew still thinks the package is installed, which can break laterbrew upgradeorbrew uninstallruns. sentry cli upgradeandsentry cli uninstalldisagree 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 callssetInstallInfo({ method: "brew", ... }). Nothing covers empty install info with a CellarexecPath.- Related: #1545, #1555.
Possible fixes
- Move
isHomebrewInstall()into a shared module, e.g.packages/cli/src/lib/binary.ts, and use it first inuninstall.tsfor bothpmMethodandisSelfManaged. It's arealpathSyncplus 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(mockrealpathSync) that asserts thebrew uninstall getsentry/tools/sentryhint and that no binary-deletion artifact is produced. - We could also add
--method brewback 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
- Đọ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 getsentry/toolkit
-
bug MCP
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getsentry/toolkit#1600 · 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 72/100
getsentry/toolkit#1471 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
getsentry/toolkit#1611 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement MCP
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
getsentry/toolkit#1601 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Use typed detector schemas from @sentry/api for metric monitorsCó thể đã có người làm @MathurAditya724 đã nhận 1 ngày trước. Đang mở
getsentry/toolkit#1595 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của getsentry/toolkit
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Nimblesite/SharpLsp#468 ·
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 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bundled uv is never updated and trusts the compromised eMudhra certificatesCó thể đã có người làm @FabienDanieau đã 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 76/100
-
bg_wait's blocking mode (stopOnAttention: false) is under-documented and effectively undiscoverableĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
nicobailon/pi-subagents#3019 ·
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 66/100
db-ux-design-system/core-web#8613 ·
Maintainer thường phản hồi trong vòng 1 ngày