Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(desktop): report a failed setup check with its cause
claude-opus-5-5-medium56925d303fc4
diff --git a/apps/desktop/src/main/local-server.test.ts b/apps/desktop/src/main/local-server.test.tsindex c137b26a..1b08a6f3 100644--- a/apps/desktop/src/main/local-server.test.ts+++ b/apps/desktop/src/main/local-server.test.ts@@ -84,6 +84,12 @@ if (args.includes("--inspect")) {while (!fs.existsSync(path.join(home, "tool-ready")))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);}+ if (fs.existsSync(path.join(home, "check-fails"))) {+ // A failed check names its cause on stderr and prints null.+ process.stderr.write("The check failed: Unsupported or changed Codex provider configuration\n");+ process.stdout.write("null\n");+ process.exit(1);+ }process.stderr.write("Checked this computer in 1.5s.\n");const reasons = eligible ? [] : ["facts-unavailable"];const reasonMessages = eligible ? [] : ["nvidia-smi was not found"];@@ -1287,6 +1293,31 @@ describe("LocalServerModule", () => {info.mockRestore();});+ it("reports a failed check with its cause instead of a crash", async () => {+ const info = vi.spyOn(silentLog, "info");+ const warn = vi.spyOn(silentLog, "warn");+ const f = fixture({ checkout: "/src" }, {}, (home) => {+ mkdirSync(home, { recursive: true });+ writeFileSync(path.join(home, "check-fails"), "");+ });+ await f.host.start();+ f.module.inspect();+ await vi.waitFor(() =>+ expect(f.module.status().localModels).toEqual({ state: "unavailable" }),+ );+ expect(warn).toHaveBeenCalledWith(+ "local_server.inspect_failed",+ expect.objectContaining({+ error: "The installer could not check this computer",+ }),+ );+ expect(info).toHaveBeenCalledWith("local_server.inspect_log", {+ line: "The check failed: Unsupported or changed Codex provider configuration",+ });+ info.mockRestore();+ warn.mockRestore();+ });+it("counts the localmodels tool download while checking", async () => {const f = fixture({ checkout: "/src" }, {}, (home) => {mkdirSync(home, { recursive: true });diff --git a/apps/desktop/src/main/local-server.ts b/apps/desktop/src/main/local-server.tsindex 25575637..44b3afe9 100644--- a/apps/desktop/src/main/local-server.ts+++ b/apps/desktop/src/main/local-server.ts@@ -597,6 +597,7 @@ export class LocalServerModule implements Module {child.once("error", reject);child.once("close", () => resolve(last));});+ // A failed check prints null; its cause is in the logged stderr.const report = JSON.parse(output) as {recommendation?: unknown;localModels?: {@@ -615,10 +616,10 @@ export class LocalServerModule implements Module {diskFreeBytes?: unknown;gpus?: { name?: unknown }[];};- };- const hardware = report.hardware;+ } | null;+ const hardware = report?.hardware;if (- typeof report.localModels?.eligible !== "boolean" ||+ typeof report?.localModels?.eligible !== "boolean" ||typeof hardware?.totalMemoryBytes !== "number")throw new Error("The installer could not check this computer");diff --git a/apps/linger-installer/src/main.ts b/apps/linger-installer/src/main.tsindex e83e7419..41f17a5b 100644--- a/apps/linger-installer/src/main.ts+++ b/apps/linger-installer/src/main.ts@@ -153,7 +153,12 @@ async function inspect(options: ReturnType<typeof parseInstallerArguments>) {})}\n`,);},- }).catch(() => null);+ }).catch((error: unknown) => {+ process.stderr.write(+ `The check failed: ${error instanceof Error ? error.message : String(error)}\n`,+ );+ return null;+ });process.stderr.write(`Checked this computer in ${((Date.now() - startedAt) / 1000).toFixed(1)}s.\n`,);diff --git a/packages/local-installation/src/setup-plan.test.ts b/packages/local-installation/src/setup-plan.test.tsindex e9d43399..c8f167d0 100644--- a/packages/local-installation/src/setup-plan.test.ts+++ b/packages/local-installation/src/setup-plan.test.ts@@ -113,6 +113,38 @@ it("fails explicitly and redacts tool output when upstream is unavailable or mal).rejects.toMatchObject({ code: "LOCALMODELS_SETUP_UNAVAILABLE" });}});+it("names the upstream cause and logs its redacted output when the check fails", async () => {+ const onEvent = vi.fn();+ await expect(+ inspectSetup({+ onEvent,+ localmodels: vi.fn(async () => ({+ code: 1,+ stdout: "",+ // A long traceback ends with its cause.+ stderr: [+ "Traceback (most recent call last):",+ ...Array.from({ length: 40 }, (_, i) => ` File "frame${i}.py"`),+ "sk-abcdefghijklmnopqrstuvwxyz",+ "error: Unsupported or changed Codex provider configuration",+ ].join("\n"),+ })),+ }),+ ).rejects.toMatchObject({+ code: "LOCALMODELS_SETUP_UNAVAILABLE",+ message: expect.stringContaining(+ "Unsupported or changed Codex provider configuration",+ ),+ });+ const messages = onEvent.mock.calls.map(([event]) => event.message);+ // The cause leads, ahead of the long output the desktop may cut off.+ expect(messages[0]).toMatch(+ /^localmodels setup inspect failed: .*Unsupported or changed Codex provider configuration$/,+ );+ const logged = messages.join("\n");+ expect(logged).toContain("localmodels setup inspect exited with code 1");+ expect(logged).not.toContain("sk-abcdefghijklmnopqrstuvwxyz");+});it("honors cancellation before invoking upstream", async () => {const localmodels = runner();await expect(diff --git a/packages/local-installation/src/setup-plan.ts b/packages/local-installation/src/setup-plan.tsindex 39017abb..6015d9bb 100644--- a/packages/local-installation/src/setup-plan.ts+++ b/packages/local-installation/src/setup-plan.ts@@ -1,6 +1,7 @@import { homedir } from "node:os";import path from "node:path";import type { InstallerEvent } from "./events.js";+import { localmodelsFailure } from "./localmodels-failure.js";import { runLocalmodels } from "./localmodels-tool.js";import { DEFAULT_GPU_SHARING } from "./setup-selection.js";@@ -125,31 +126,41 @@ export async function inspectSetup(const home = path.resolve(options.home ?? path.join(options.userHome ?? homedir(), ".simplexai"),);+ let failure: string | undefined;try {- const result = await (options.localmodels ?? runLocalmodels)(- home,- [- "setup",- "inspect",- "--root",- path.join(home, "runtime", "harness"),- "--model-base-dir",- path.join(home, "runtime", "localmodels", "models"),- "--decision",- "none",- "--offline",- "--defer-services",- ...((options.shareGpu ?? DEFAULT_GPU_SHARING) ? ["--share-gpu"] : []),- "--json",- ],- {- signal: options.signal,- timeoutMs: 120000,- ...(options.onEvent ? { onEvent: options.onEvent } : {}),- },- );+ const args = [+ "setup",+ "inspect",+ "--root",+ path.join(home, "runtime", "harness"),+ "--model-base-dir",+ path.join(home, "runtime", "localmodels", "models"),+ "--decision",+ "none",+ "--offline",+ "--defer-services",+ ...((options.shareGpu ?? DEFAULT_GPU_SHARING) ? ["--share-gpu"] : []),+ "--json",+ ];+ const result = await (options.localmodels ?? runLocalmodels)(home, args, {+ signal: options.signal,+ timeoutMs: 120000,+ ...(options.onEvent ? { onEvent: options.onEvent } : {}),+ });options.signal?.throwIfAborted();- if (result.code !== 0) throw new Error("Upstream setup failed");+ if (result.code !== 0) {+ const { cause, log } = localmodelsFailure(args, result);+ // The cause goes first: the desktop logs only the first stderr lines,+ // and the full output after it can be a long traceback.+ if (cause)+ options.onEvent?.({+ kind: "log",+ message: `localmodels setup inspect failed: ${cause}`,+ });+ for (const message of log) options.onEvent?.({ kind: "log", message });+ failure = cause;+ throw new Error("Upstream setup failed");+ }const value = JSON.parse(result.stdout) as UpstreamReport;if (value.schema !== "localmodels.setup-report/v1" ||@@ -226,7 +237,9 @@ export async function inspectSetup(options.signal?.throwIfAborted();throw Object.assign(new Error(- "The localmodels setup report is unavailable. Check the verified tool installation and retry.",+ failure+ ? `The localmodels setup check failed: ${failure}`+ : "The localmodels setup report is unavailable. Check the verified tool installation and retry.",),{ code: "LOCALMODELS_SETUP_UNAVAILABLE" },);