fix(pi): reject broken managed tool binaries

This commit is contained in:
2026-09-14 10:57:23 -04:00
parent a8a18d27e9
commit 212ed506a2

View File

@@ -72,8 +72,8 @@ const TOOLS: Record<string, ToolConfig> = {
function commandExists(cmd: string): boolean { function commandExists(cmd: string): boolean {
try { try {
const result = spawnSync(cmd, ["--version"], { stdio: "pipe" }); const result = spawnSync(cmd, ["--version"], { stdio: "pipe" });
// Check for ENOENT error (command not found) // Downloaded generic Linux binaries can exist but fail on NixOS before they print a version.
return result.error === undefined || result.error === null; return (result.error === undefined || result.error === null) && result.status === 0;
} catch { } catch {
return false; return false;
} }
@@ -86,7 +86,7 @@ export function getToolPath(tool: "fd" | "rg"): string | null {
// Check our tools directory first // Check our tools directory first
const localPath = join(TOOLS_DIR, config.binaryName + (platform() === "win32" ? ".exe" : "")); const localPath = join(TOOLS_DIR, config.binaryName + (platform() === "win32" ? ".exe" : ""));
if (existsSync(localPath)) { if (existsSync(localPath) && commandExists(localPath)) {
return localPath; return localPath;
} }