From 2da2ef30f7b3ba937087a05cc1287a2e093edccd Mon Sep 17 00:00:00 2001 From: jackwener Date: Mon, 23 Mar 2026 15:54:25 +0800 Subject: [PATCH] fix: ensure standard PATH is available for external CLIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some environments (GUI apps, cron, IDE terminals) launch with a minimal PATH that excludes standard directories like /usr/local/bin and /usr/sbin. This causes external CLIs to fail when they try to run system commands (e.g. sysctl). Fix by ensuring standard system paths exist in process.env.PATH at startup. This is a one-time fix that benefits ALL child processes — isBinaryInstalled(), installExternalCli(), daemon spawn, etc. — without needing per-call env patching. Fixes #284 --- src/main.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.ts b/src/main.ts index 3d5e2426..59ee5896 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,16 @@ * opencli — Make any website your CLI. AI-powered. */ +// Ensure standard system paths are available for child processes. +// Some environments (GUI apps, cron, IDE terminals) launch with a minimal PATH +// that excludes /usr/local/bin, /usr/sbin, etc., causing external CLIs to fail. +if (process.platform !== 'win32') { + const std = ['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin']; + const cur = new Set((process.env.PATH ?? '').split(':').filter(Boolean)); + for (const p of std) cur.add(p); + process.env.PATH = [...cur].join(':'); +} + import * as os from 'node:os'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url';