[PR #4557] [MERGED] fix(ghidra): resolve keg-only Homebrew openjdk on macOS (#4556) #6306

Closed
opened 2026-10-31 01:13:27 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4557
Author: @vadlachary2002
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @morluto

Base: main ← Head: patch-1


📝 Commits (4)

  • 139537c fix(ghidra): resolve keg-only Homebrew openjdk on macOS (#4556)
  • 4709e43 fix(ghidra): fix javaHome type narrowing in java candidate list (#4556)
  • f5d034a fix(ghidra): order homebrew java candidates by host architecture (#4556)
  • c0accec fix(ghidra): resolve Homebrew Java discovery merge conflicts

📊 Changes

2 files changed (+109 additions, -10 deletions)

View changed files

📝 src/ghidra/GhidraInstallation.test.ts (+77 -0)
📝 src/ghidra/GhidraInstallation.ts (+32 -10)

📄 Description

Fixes an issue where rea doctor --provider ghidra fails the ghidra-java check on macOS when OpenJDK is installed via Homebrew. Homebrew's openjdk is keg-only, so it is neither on PATH nor resolved by /usr/libexec/java_home.

Fixes #4556

Problem and expected behavior

Problem: When options.javaHome is undefined, the provider defaulted to a bare "java" command. On a default macOS setup with Homebrew (brew install ghidra openjdk), java is not available on PATH, causing REA to report detail: java with status missing_dependency even though a fully functional JDK exists in Homebrew's keg directory.

Expected behavior: ghidra-java checks standard Homebrew installation paths for a usable JDK before reporting it as missing, allowing rea doctor to pass without requiring manual JAVA_HOME configuration.

Change and scope

When javaHome is unset on macOS, preserve Java on the caller's absolute PATH entries; otherwise check the standard Homebrew OpenJDK paths, preferring /opt/homebrew for arm64 and /usr/local for x64. Retain the bare Java command if no Homebrew executable is found. Explicit JAVA_HOME remains authoritative, and Linux/Windows keep their existing selection.

The merge resolution preserves main's typed Java probe results and its refusal to execute relative JAVA_HOME paths. Discovery checks absolute executable paths rather than interpreting a file named java in the working directory as a PATH match. Added six regression cases for macOS architecture preference, caller PATH, explicit JAVA_HOME, and Linux/Windows selection.

Contract and boundary impact

  • Semantic owner and earliest changed stage: ghidra provider admission / setup check (inspectGhidraInstallation).
  • Contribution scope fit and linked maintainer decision: Not applicable (ordinary fix within existing provider setup boundaries).
  • CLI and MCP/tool-catalog contract: None.
  • Provider, bridge, target-format, or platform compatibility: macOS (darwin/arm64 and darwin/x64) with Homebrew-installed OpenJDK.
  • Evidence, artifact, provenance, or reconstruction contract: None.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Not applicable.
  • Generated metadata, package, or installation impact: None.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: Six installation-discovery regression cases; existing Java probe and doctor boundary tests also passed.
  • Base reproduction or other evidence: On macOS with brew install ghidra openjdk and JAVA_HOME unset, rea doctor --provider ghidra returned ghidra-java: ok: false, detail: java.
  • User-visible CLI/MCP output (if applicable): rea doctor --provider ghidra now passes all checks including ghidra-java.
  • Remaining proof gaps: The merge resolution was not verified against real Homebrew/Ghidra installations. Executable PATH Java remains authoritative even if it is the macOS stub or an unsupported JDK; automatic retry after a failed Java probe is not implemented.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Merge-resolution validation

Merged main at 360626434 in c0accec68. Executed with Node 24.18.0 on macOS:

  • npm run test:focused -- src/ghidra/GhidraInstallation.test.ts src/ghidra/GhidraJavaProbe.test.ts tests/boundary/filesystem/ghidraJavaProbe.test.ts tests/boundary/cli/ghidraJavaDoctor.test.ts: passed, 121 tests across four files. Discovery uses simulated host observations; doctor tests use controlled Java processes.
  • npm run check:fast: passed (typecheck and lint).
  • git diff origin/main...HEAD --check: passed.
  • Real-provider verification was not rerun for this resolution; the author's earlier result below applies to the earlier revision.

Original author validation (before merge resolution)

  • env -u JAVA_HOME GHIDRA_INSTALL_DIR=/opt/homebrew/Cellar/ghidra/12.1.4/libexec PATH="/usr/bin:/bin:/opt/homebrew/bin" rea doctor --provider ghidra — ghidra-java reports ok: true.

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: Ghidra 12.1.4 on macOS (darwin/arm64).
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Safe; all newly probed paths are absolute standard Homebrew system paths.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/4557 **Author:** [@vadlachary2002](https://github.com/vadlachary2002) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (4) - [`139537c`](https://github.com/morluto/rea/commit/139537c1e5ce4156fd222f5b649db313a823b2da) fix(ghidra): resolve keg-only Homebrew openjdk on macOS (#4556) - [`4709e43`](https://github.com/morluto/rea/commit/4709e433831d15617abe20a37725991dc0747074) fix(ghidra): fix javaHome type narrowing in java candidate list (#4556) - [`f5d034a`](https://github.com/morluto/rea/commit/f5d034a3b3c4585c54360f10dc8087ca54bb886a) fix(ghidra): order homebrew java candidates by host architecture (#4556) - [`c0accec`](https://github.com/morluto/rea/commit/c0accec68972ae06af0770d65581506aabddd7e3) fix(ghidra): resolve Homebrew Java discovery merge conflicts ### 📊 Changes **2 files changed** (+109 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/ghidra/GhidraInstallation.test.ts` (+77 -0) 📝 `src/ghidra/GhidraInstallation.ts` (+32 -10) </details> ### 📄 Description Fixes an issue where `rea doctor --provider ghidra` fails the `ghidra-java` check on macOS when OpenJDK is installed via Homebrew. Homebrew's `openjdk` is keg-only, so it is neither on `PATH` nor resolved by `/usr/libexec/java_home`. Fixes #4556 ## Problem and expected behavior **Problem:** When `options.javaHome` is undefined, the provider defaulted to a bare `"java"` command. On a default macOS setup with Homebrew (`brew install ghidra openjdk`), `java` is not available on `PATH`, causing REA to report `detail: java` with status `missing_dependency` even though a fully functional JDK exists in Homebrew's keg directory. **Expected behavior:** `ghidra-java` checks standard Homebrew installation paths for a usable JDK before reporting it as missing, allowing `rea doctor` to pass without requiring manual `JAVA_HOME` configuration. ## Change and scope When `javaHome` is unset on macOS, preserve Java on the caller's absolute PATH entries; otherwise check the standard Homebrew OpenJDK paths, preferring `/opt/homebrew` for arm64 and `/usr/local` for x64. Retain the bare Java command if no Homebrew executable is found. Explicit `JAVA_HOME` remains authoritative, and Linux/Windows keep their existing selection. The merge resolution preserves main's typed Java probe results and its refusal to execute relative `JAVA_HOME` paths. Discovery checks absolute executable paths rather than interpreting a file named `java` in the working directory as a PATH match. Added six regression cases for macOS architecture preference, caller PATH, explicit JAVA_HOME, and Linux/Windows selection. ## Contract and boundary impact - Semantic owner and earliest changed stage: `ghidra` provider admission / setup check (`inspectGhidraInstallation`). - Contribution scope fit and linked maintainer decision: Not applicable (ordinary fix within existing provider setup boundaries). - CLI and MCP/tool-catalog contract: None. - Provider, bridge, target-format, or platform compatibility: macOS (`darwin/arm64` and `darwin/x64`) with Homebrew-installed OpenJDK. - Evidence, artifact, provenance, or reconstruction contract: None. - Target selection, authority, upstream behavior, and cleanup details (if applicable): Not applicable. - Generated metadata, package, or installation impact: None. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: Six installation-discovery regression cases; existing Java probe and doctor boundary tests also passed. - Base reproduction or other evidence: On macOS with `brew install ghidra openjdk` and `JAVA_HOME` unset, `rea doctor --provider ghidra` returned `ghidra-java: ok: false, detail: java`. - User-visible CLI/MCP output (if applicable): `rea doctor --provider ghidra` now passes all checks including `ghidra-java`. - Remaining proof gaps: The merge resolution was not verified against real Homebrew/Ghidra installations. Executable PATH Java remains authoritative even if it is the macOS stub or an unsupported JDK; automatic retry after a failed Java probe is not implemented. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Merge-resolution validation Merged main at `360626434` in `c0accec68`. Executed with Node 24.18.0 on macOS: - `npm run test:focused -- src/ghidra/GhidraInstallation.test.ts src/ghidra/GhidraJavaProbe.test.ts tests/boundary/filesystem/ghidraJavaProbe.test.ts tests/boundary/cli/ghidraJavaDoctor.test.ts`: passed, 121 tests across four files. Discovery uses simulated host observations; doctor tests use controlled Java processes. - `npm run check:fast`: passed (typecheck and lint). - `git diff origin/main...HEAD --check`: passed. - Real-provider verification was not rerun for this resolution; the author's earlier result below applies to the earlier revision. ## Original author validation (before merge resolution) - `env -u JAVA_HOME GHIDRA_INSTALL_DIR=/opt/homebrew/Cellar/ghidra/12.1.4/libexec PATH="/usr/bin:/bin:/opt/homebrew/bin" rea doctor --provider ghidra` — `ghidra-java` reports `ok: true`. ## Compatibility, safety, and release - Breaking changes or migration steps: None. - Real Hopper/Ghidra, browser, or OS coverage: Ghidra 12.1.4 on macOS (`darwin/arm64`). - Package or release metadata impact: None. - Security, privacy, process, or containment review: Safe; all newly probed paths are absolute standard Homebrew system paths. ## Author readiness Human owner: <!-- @GitHub-handle --> - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [ ] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:27 +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#6306
No description provided.