fix(ghidra): do not run Java from a relative JAVA_HOME in doctor and setup

The installation inspection rejected a relative JAVA_HOME, but only after
it had already probed `<JAVA_HOME>/bin/java` with spawnSync. `rea doctor`
and `rea setup` therefore ran whatever `jdk/bin/java` (or `bin/java` for
an empty JAVA_HOME) the current directory held, while reporting the
setting as rejected.

Skip the probe when JAVA_HOME is not absolute on the inspected platform.
The configuration check still reports the rejection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-09 07:59:38 +00:00
co-authored by Claude Opus 5.5
parent e6905c18e0
commit c3f169823f
2 changed files with 39 additions and 4 deletions
+30
View File
@@ -413,6 +413,36 @@ describe("Ghidra configuration paths", () => {
},
);
it.each([
["linux", "./jdk"],
["linux", ""],
["win32", "jdk"],
] as const)(
"does not run Java from a relative JAVA_HOME (%s %o)",
(platform, javaHome) => {
const probed: string[] = [];
const result = inspectGhidraInstallation(
{
installDir: platform === "win32" ? WINDOWS_INSTALL : INSTALL,
javaHome,
platform,
architecture: "x64",
},
host({
probeJava: (command) => {
probed.push(command);
return JAVA;
},
}),
);
expect(probed).toEqual([]);
expect(result).toMatchObject({
status: "unavailable",
rejection: { code: "not_configured" },
});
},
);
it("judges absolute paths by the inspected platform", () => {
const result = inspectGhidraInstallation(
{ installDir: "C:\\ghidra", platform: "win32", architecture: "x64" },
+9 -4
View File
@@ -292,10 +292,15 @@ const installationCoordinates = (
? undefined
: ghidraApplicationProperties(properties),
javaCommand,
java: host.probeJava(
javaCommand,
ghidraJavaEnvironment(options.javaHome, process.env, platform),
),
// The configuration check rejects a relative JAVA_HOME. Probing it would
// run whatever `bin/java` the current directory holds.
java:
options.javaHome === undefined || path.isAbsolute(options.javaHome)
? host.probeJava(
javaCommand,
ghidraJavaEnvironment(options.javaHome, process.env, platform),
)
: undefined,
};
};