[PR #1182] [MERGED] fix(doctor): find the Homebrew Hopper cask without writing Homebrew caches #2705

Closed
opened 2026-10-17 21:09:18 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1182
Author: @kaoru0822-kitauji
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/doctor-hopper-discovery-readonly


📝 Commits (1)

  • a503376 fix(doctor): find the Homebrew Hopper cask without writing Homebrew caches

📊 Changes

3 files changed (+135 additions, -4 deletions)

View changed files

📝 src/application/Doctor.systemHost.test.ts (+65 -0)
📝 src/application/Doctor.ts (+14 -4)
📝 src/application/homebrew.ts (+56 -0)

📄 Description

Summary

docs/installation.md calls rea doctor --json "strictly read-only". On a Mac without Hopper in /Applications or ~/Applications, doctor fell back to brew --prefix --cask hopper-disassembler. Any brew command that names a cask first fetches and caches Homebrew's cask API and bootsnap data, so each doctor run wrote about 600 files (~36 MB) under ~/Library/Caches/Homebrew, and needed the network to do it. On current Homebrew the command also fails with Error: invalid option: --cask, so the fallback never found Hopper.

Fixes #1165

Change

  • src/application/Doctor.ts: brewHopperPath now runs only brew --caskroom, which brew answers from its shell wrapper without loading the cask API. It then looks for the cask under that Caskroom.
  • src/application/homebrew.ts: installedCaskAppdir reads <Caskroom>/hopper-disassembler/.metadata/config.json, the configuration Homebrew records at install time, and returns the application directory in Homebrew's precedence (explicit --appdir, then environment, then default), expanding ~/. The candidate is <appdir>/Hopper Disassembler.app/Contents/MacOS/hopper, the cask's app artifact; doctor still confirms it is executable. A missing, unreadable, or malformed receipt means no Homebrew candidate.

This keeps the intent of the existing "detects a Homebrew cask installed outside /Applications" test: a cask installed with a custom --appdir is now actually found. The default appdir case is still found by the /Applications scan.

Measured (macOS arm64, Homebrew at /opt/homebrew, Hopper not installed)

Command in a fresh HOME Files written
brew --prefix --cask hopper-disassembler (old probe) 625, and invalid option: --cask
brew --caskroom hopper-disassembler 710
brew --caskroom (new probe) 0
rea doctor --client codex --json on this branch 0 (exit 1: no Codex config, as expected)

Tests

src/application/Doctor.systemHost.test.ts:

  • with a Caskroom receipt using the default, environment, and explicit ~/ appdir, the system host returns the Hopper path in the recorded appdir, and the only brew invocation is ["--caskroom"];
  • with no receipt, it returns no candidate.

Both fail on main.

Verification

  • npm run check:fast, npm run jscpd
  • npm run test:focused -- the 20 doctor test files under src/ and tests/boundary/ (178 passed)
  • Built CLI in a fresh HOME, as above

No real Hopper verification was needed: Hopper launching is unchanged, and only the discovery fallback that runs when Hopper is absent from standard locations changed. I did not install the Hopper cask to verify a positive Homebrew discovery; that path is covered by the receipt tests.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1182 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/doctor-hopper-discovery-readonly` --- ### 📝 Commits (1) - [`a503376`](https://github.com/morluto/rea/commit/a503376b2f9d9ba14d1602e58e0e93059e9d9181) fix(doctor): find the Homebrew Hopper cask without writing Homebrew caches ### 📊 Changes **3 files changed** (+135 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/application/Doctor.systemHost.test.ts` (+65 -0) 📝 `src/application/Doctor.ts` (+14 -4) 📝 `src/application/homebrew.ts` (+56 -0) </details> ### 📄 Description ## Summary `docs/installation.md` calls `rea doctor --json` "strictly read-only". On a Mac without Hopper in `/Applications` or `~/Applications`, doctor fell back to `brew --prefix --cask hopper-disassembler`. Any brew command that names a cask first fetches and caches Homebrew's cask API and bootsnap data, so each doctor run wrote about 600 files (~36 MB) under `~/Library/Caches/Homebrew`, and needed the network to do it. On current Homebrew the command also fails with `Error: invalid option: --cask`, so the fallback never found Hopper. Fixes #1165 ## Change - `src/application/Doctor.ts`: `brewHopperPath` now runs only `brew --caskroom`, which brew answers from its shell wrapper without loading the cask API. It then looks for the cask under that Caskroom. - `src/application/homebrew.ts`: `installedCaskAppdir` reads `<Caskroom>/hopper-disassembler/.metadata/config.json`, the configuration Homebrew records at install time, and returns the application directory in Homebrew's precedence (explicit `--appdir`, then environment, then default), expanding `~/`. The candidate is `<appdir>/Hopper Disassembler.app/Contents/MacOS/hopper`, the cask's `app` artifact; doctor still confirms it is executable. A missing, unreadable, or malformed receipt means no Homebrew candidate. This keeps the intent of the existing "detects a Homebrew cask installed outside /Applications" test: a cask installed with a custom `--appdir` is now actually found. The default appdir case is still found by the `/Applications` scan. ## Measured (macOS arm64, Homebrew at `/opt/homebrew`, Hopper not installed) | Command in a fresh `HOME` | Files written | |---|---| | `brew --prefix --cask hopper-disassembler` (old probe) | 625, and `invalid option: --cask` | | `brew --caskroom hopper-disassembler` | 710 | | `brew --caskroom` (new probe) | 0 | | `rea doctor --client codex --json` on this branch | 0 (exit 1: no Codex config, as expected) | ## Tests `src/application/Doctor.systemHost.test.ts`: - with a Caskroom receipt using the default, environment, and explicit `~/` appdir, the system host returns the Hopper path in the recorded appdir, and the only brew invocation is `["--caskroom"]`; - with no receipt, it returns no candidate. Both fail on `main`. ## Verification - `npm run check:fast`, `npm run jscpd` - `npm run test:focused --` the 20 doctor test files under `src/` and `tests/boundary/` (178 passed) - Built CLI in a fresh `HOME`, as above No real Hopper verification was needed: Hopper launching is unchanged, and only the discovery fallback that runs when Hopper is absent from standard locations changed. I did not install the Hopper cask to verify a positive Homebrew discovery; that path is covered by the receipt tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:09:18 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2705
No description provided.