[GH-ISSUE #4657] [Bug] macOS: Homebrew keg-only JDK is never tried when /usr/bin/java is present (follow-up to #4556) #2425

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

Originally created by @RishTheFish21 on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/4657

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

Setup, packaging, or upgrade

Observed behavior

#4557 added Homebrew keg-only OpenJDK discovery for #4556. But discovery only runs when no executable java exists on PATH. Every Mac has /usr/bin/java. Without a registered JDK it's Apple's launcher, which prints "Unable to locate a Java Runtime" and exits 1. REA selects it, the probe fails, and the Homebrew keg is never tried. So rea doctor --provider ghidra still fails ghidra-java with a working keg-only JDK installed.

Greptile and Codex both flagged this on #4557 (P1), and the PR listed it as a known gap.

Reproduction

On main (includes 8267edc), macOS arm64, Homebrew openjdk 27 installed keg-only:

  1. Make a java that behaves like the launcher with no registered JDK:
    mkdir -p /tmp/fakejava
    printf '#!/bin/sh\necho "The operation could not be completed. Unable to locate a Java Runtime." >&2\nexit 1\n' > /tmp/fakejava/java
    chmod +x /tmp/fakejava/java
  2. env -u JAVA_HOME PATH="/tmp/fakejava:/usr/bin:/bin:$(dirname "$(command -v node)")" node scripts/rea.mjs doctor --provider ghidra
  3. env JAVA_HOME=/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home node scripts/rea.mjs doctor --provider ghidra

Reproduced 1/1. My Mac has a registered JDK, so the fake java stands in for /usr/bin/java on a Mac without one.

Expected behavior

With JAVA_HOME unset, a PATH java that runs should still win. When it can't run, REA should try the Homebrew keg paths that #4557 added, as docs/installation.md and #4556 describe.

Impact and scope

Affects the default macOS setup with keg-only Homebrew OpenJDK and no other registered JDK. In that setup, the #4557 discovery never runs. The workaround is still to export JAVA_HOME. Intel Macs (/usr/local prefix) were not tested.

REA version

source commit <5c0472c57> (main), package 6.5.0

Runtime and platform

ode 24.18.0; macOS arm64; Ghidra 12.1.4; Homebrew openjdk 27 (keg-only)

Target and artifact context

not applicable

Interface

CLI

Earliest failure stage

Setup or provider admission

Relevant output or evidence

Step 2 (fake launcher first on PATH, keg installed):
ghidra-java ok: false runtime_failure detail: "java: Java exited 1"
stderr: "The operation could not be completed. Unable to locate a Java Runtime.\n" exit_code: 1

Step 3 (JAVA_HOME at the keg):
ghidra-java ok: true detail: 27; 64-bit; JDK; /opt/homebrew/Cellar/openjdk/27/libexec/openjdk.jdk/Contents/Home

Source: src/ghidra/GhidraInstallation.ts on main returns bare "java" as soon as any absolute PATH directory contains an executable java, before the Homebrew candidates are considered.

Typed outcome or recovery expected

Source-derived: the choice is made by checking that java exists on PATH, not that it runs. Probing PATH Java first and falling back to the kegs only when that probe fails would keep a working PATH Java authoritative.

Analysis or suspected cause

Follow-up to #4556 / #4557. I have a fix with regression tests ready (PATH Java wins when it runs; keg fallback when it fails; the PATH failure is still reported when both fail) and would like to take this.

Additional context

No response

Originally created by @RishTheFish21 on GitHub (Oct 17, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/4657 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area Setup, packaging, or upgrade ### Observed behavior #4557 added Homebrew keg-only OpenJDK discovery for #4556. But discovery only runs when no executable `java` exists on PATH. Every Mac has `/usr/bin/java`. Without a registered JDK it's Apple's launcher, which prints "Unable to locate a Java Runtime" and exits 1. REA selects it, the probe fails, and the Homebrew keg is never tried. So `rea doctor --provider ghidra` still fails `ghidra-java` with a working keg-only JDK installed. Greptile and Codex both flagged this on #4557 (P1), and the PR listed it as a known gap. ### Reproduction On main (includes 8267edc), macOS arm64, Homebrew openjdk 27 installed keg-only: 1. Make a `java` that behaves like the launcher with no registered JDK: mkdir -p /tmp/fakejava printf '#!/bin/sh\necho "The operation could not be completed. Unable to locate a Java Runtime." >&2\nexit 1\n' > /tmp/fakejava/java chmod +x /tmp/fakejava/java 2. env -u JAVA_HOME PATH="/tmp/fakejava:/usr/bin:/bin:$(dirname "$(command -v node)")" node scripts/rea.mjs doctor --provider ghidra 3. env JAVA_HOME=/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home node scripts/rea.mjs doctor --provider ghidra Reproduced 1/1. My Mac has a registered JDK, so the fake `java` stands in for /usr/bin/java on a Mac without one. ### Expected behavior With JAVA_HOME unset, a PATH `java` that runs should still win. When it can't run, REA should try the Homebrew keg paths that #4557 added, as docs/installation.md and #4556 describe. ### Impact and scope Affects the default macOS setup with keg-only Homebrew OpenJDK and no other registered JDK. In that setup, the #4557 discovery never runs. The workaround is still to export JAVA_HOME. Intel Macs (/usr/local prefix) were not tested. ### REA version source commit <5c0472c57> (main), package 6.5.0 ### Runtime and platform ode 24.18.0; macOS arm64; Ghidra 12.1.4; Homebrew openjdk 27 (keg-only) ### Target and artifact context not applicable ### Interface CLI ### Earliest failure stage Setup or provider admission ### Relevant output or evidence Step 2 (fake launcher first on PATH, keg installed): ghidra-java ok: false runtime_failure detail: "java: Java exited 1" stderr: "The operation could not be completed. Unable to locate a Java Runtime.\n" exit_code: 1 Step 3 (JAVA_HOME at the keg): ghidra-java ok: true detail: 27; 64-bit; JDK; /opt/homebrew/Cellar/openjdk/27/libexec/openjdk.jdk/Contents/Home Source: src/ghidra/GhidraInstallation.ts on main returns bare "java" as soon as any absolute PATH directory contains an executable `java`, before the Homebrew candidates are considered. ### Typed outcome or recovery expected Source-derived: the choice is made by checking that `java` exists on PATH, not that it runs. Probing PATH Java first and falling back to the kegs only when that probe fails would keep a working PATH Java authoritative. ### Analysis or suspected cause Follow-up to #4556 / #4557. I have a fix with regression tests ready (PATH Java wins when it runs; keg fallback when it fails; the PATH failure is still reported when both fail) and would like to take this. ### Additional context _No response_
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#2425
No description provided.