[PR #4671] [CLOSED] fix(ghidra): try keg-only Homebrew JDK when PATH java cannot run #6355

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4671
Author: @kevin9327
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix/macos-keg-java-fallback


📝 Commits (2)

  • 159caf7 fix(ghidra): try keg-only Homebrew JDK when PATH java cannot run
  • 28e2976 Merge branch 'main' into fix/macos-keg-java-fallback

📊 Changes

2 files changed (+136 additions, -52 deletions)

View changed files

📝 src/ghidra/GhidraInstallation.test.ts (+64 -2)
📝 src/ghidra/GhidraInstallation.ts (+72 -50)

📄 Description

Summary

Fixes #4657 (follow-up to #4556 / #4557). On macOS with JAVA_HOME unset, Ghidra Java discovery now falls back to the Homebrew keg-only OpenJDK when the java on PATH cannot run. Before, the keg paths were tried only when no java was on PATH, and every Mac has /usr/bin/java.

Problem and expected behavior

Without a registered JDK, /usr/bin/java is Apple's launcher stub. It prints "Unable to locate a Java Runtime" and exits 1. REA selected it, the probe failed with runtime_unavailable, and rea doctor --provider ghidra failed ghidra-java even with a working keg-only JDK installed. Expected: a PATH java that runs still wins. When it cannot run, REA tries the keg paths that #4557 added.

Change and scope

In inspectCoordinates (src/ghidra/GhidraInstallation.ts), Java selection and probing are now one step:

  • JAVA_HOME set, or a non-darwin platform: unchanged.
  • darwin with no PATH java: unchanged (first executable keg candidate, else java).
  • darwin with a PATH java: probe it. If the probe fails with runtime_missing or runtime_unavailable, probe the executable keg candidates in architecture order and select the first that succeeds. If none succeeds, the PATH probe result and its remediation are reported as before. Other probe failures (for example version_unresolved) keep the PATH java, so its diagnostics are not hidden.

Not included: an Intel-Mac real-hardware check, and any change to the remediation text. Scope decision: not applicable (ordinary fix within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra installation inspection (Java selection).

  • Contribution scope fit and linked maintainer decision: bug fix; not applicable.

  • CLI and MCP/tool-catalog contract: none.

  • Provider, bridge, target-format, or platform compatibility: macOS only; other platforms are unchanged.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process. (an extra java -version probe of the keg JDK, only after the PATH java fails)

Evidence and regression coverage

  • Tests added or updated: new macOS PATH java with a keg-only Homebrew JDK (#4657) block. "falls back to the keg when the PATH java is Apple's launcher stub" probes java, then the keg, and passes the java check. "keeps a PATH java that runs" probes only java. The existing preserves selected Java on darwin case now expects the keg paths to be checked (not probed, because none is executable there) after the PATH java fails.
  • Base reproduction: with the source change stashed, the new fallback test fails (only java is probed and the java check fails). The updated darwin case also fails on base, which shows the old code never looked at the keg.
  • Remaining proof gaps: unit tests with an injected host only. I did not run rea doctor on a real Mac without a registered JDK.

Validation performed

  • npx vitest run src/ghidra/GhidraInstallation.test.ts — 91 passed (2 failed on base).
  • npx vitest run src/ghidra — 668 passed.
  • npx tsc --noEmit -p . — clean.
  • npx oxfmt on the changed files; npx oxlint on them shows only two existing warnings at an unrelated function (line ~870).

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: none (unit-level only).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the extra probe runs only fixed Homebrew paths that already were candidates, never a PATH-relative or working-directory binary.

AI assistance: an AI coding agent (Grok Bot) wrote this change and these tests. As the template requires, the human owner declarations below are left for me to complete myself, so this PR is opened as a draft.

Author readiness

Human owner: @kevin9327

  • 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/4671 **Author:** [@kevin9327](https://github.com/kevin9327) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/macos-keg-java-fallback` --- ### 📝 Commits (2) - [`159caf7`](https://github.com/morluto/rea/commit/159caf790081bb401d66af04974bc758e3693a62) fix(ghidra): try keg-only Homebrew JDK when PATH java cannot run - [`28e2976`](https://github.com/morluto/rea/commit/28e29761c67301ba3dd52cd236ed9c51a4376961) Merge branch 'main' into fix/macos-keg-java-fallback ### 📊 Changes **2 files changed** (+136 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `src/ghidra/GhidraInstallation.test.ts` (+64 -2) 📝 `src/ghidra/GhidraInstallation.ts` (+72 -50) </details> ### 📄 Description ## Summary Fixes #4657 (follow-up to #4556 / #4557). On macOS with `JAVA_HOME` unset, Ghidra Java discovery now falls back to the Homebrew keg-only OpenJDK when the `java` on PATH cannot run. Before, the keg paths were tried only when no `java` was on PATH, and every Mac has `/usr/bin/java`. ## Problem and expected behavior Without a registered JDK, `/usr/bin/java` is Apple's launcher stub. It prints "Unable to locate a Java Runtime" and exits 1. REA selected it, the probe failed with `runtime_unavailable`, and `rea doctor --provider ghidra` failed `ghidra-java` even with a working keg-only JDK installed. Expected: a PATH `java` that runs still wins. When it cannot run, REA tries the keg paths that #4557 added. ## Change and scope In `inspectCoordinates` (`src/ghidra/GhidraInstallation.ts`), Java selection and probing are now one step: - `JAVA_HOME` set, or a non-darwin platform: unchanged. - darwin with no PATH `java`: unchanged (first executable keg candidate, else `java`). - darwin with a PATH `java`: probe it. If the probe fails with `runtime_missing` or `runtime_unavailable`, probe the executable keg candidates in architecture order and select the first that succeeds. If none succeeds, the PATH probe result and its remediation are reported as before. Other probe failures (for example `version_unresolved`) keep the PATH java, so its diagnostics are not hidden. Not included: an Intel-Mac real-hardware check, and any change to the remediation text. Scope decision: not applicable (ordinary fix within existing boundaries). ## Contract and boundary impact - Semantic owner and earliest changed stage: Ghidra installation inspection (Java selection). - Contribution scope fit and linked maintainer decision: bug fix; not applicable. - CLI and MCP/tool-catalog contract: none. - Provider, bridge, target-format, or platform compatibility: macOS only; other platforms are unchanged. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. - [x] Read existing files or captured data. - [x] Launch or attach to a process. (an extra `java -version` probe of the keg JDK, only after the PATH java fails) ## Evidence and regression coverage - Tests added or updated: new `macOS PATH java with a keg-only Homebrew JDK (#4657)` block. "falls back to the keg when the PATH java is Apple's launcher stub" probes `java`, then the keg, and passes the java check. "keeps a PATH java that runs" probes only `java`. The existing `preserves selected Java on darwin` case now expects the keg paths to be *checked* (not probed, because none is executable there) after the PATH java fails. - Base reproduction: with the source change stashed, the new fallback test fails (only `java` is probed and the java check fails). The updated darwin case also fails on base, which shows the old code never looked at the keg. - Remaining proof gaps: unit tests with an injected host only. I did not run `rea doctor` on a real Mac without a registered JDK. ## Validation performed - `npx vitest run src/ghidra/GhidraInstallation.test.ts` — 91 passed (2 failed on base). - `npx vitest run src/ghidra` — 668 passed. - `npx tsc --noEmit -p .` — clean. - `npx oxfmt` on the changed files; `npx oxlint` on them shows only two existing warnings at an unrelated function (line ~870). ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: none (unit-level only). - Package or release metadata impact: none. - Security, privacy, process, or containment review: the extra probe runs only fixed Homebrew paths that already were candidates, never a PATH-relative or working-directory binary. AI assistance: an AI coding agent (Grok Bot) wrote this change and these tests. As the template requires, the human owner declarations below are left for me to complete myself, so this PR is opened as a draft. ## Author readiness Human owner: @kevin9327 - [ ] 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. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [ ] 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:48 +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#6355
No description provided.