Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/helpers/llamaCppInstaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,19 @@ class LlamaCppInstaller {

async getSystemBinaryPath() {
return new Promise((resolve) => {
// Cross-platform command resolution
const checkCmd = this.platform === "win32" ? "where" : "which";
// Cross-platform command resolution.
// On Windows use where.exe with shell:false so PATH lookup does not
// depend on cmd.exe and CRLF stdout is handled below.
const checkCmd = this.platform === "win32" ? "where.exe" : "which";
const binaryNames = this.platform === "win32" ? ["llama-server.exe"] : ["llama-server"];

let found = false;
let remaining = binaryNames.length;

for (const name of binaryNames) {
const proc = spawn(checkCmd, [name], {
shell: true,
shell: false,
windowsHide: true,
stdio: "pipe",
});

Expand All @@ -95,7 +98,7 @@ class LlamaCppInstaller {
proc.on("close", (code) => {
if (!found && code === 0 && output) {
found = true;
resolve(output.trim().split("\n")[0]);
resolve(output.trim().split(/\r?\n/)[0]);
}
remaining--;
if (remaining === 0 && !found) {
Expand Down