Skip to content

Commit 22f5c7a

Browse files
fix: ensure standard PATH is available for external CLIs (#285)
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 Co-authored-by: jackwener <jakevingoo@gmail.com>
1 parent 8ab0cd2 commit 22f5c7a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
* opencli — Make any website your CLI. AI-powered.
44
*/
55

6+
// Ensure standard system paths are available for child processes.
7+
// Some environments (GUI apps, cron, IDE terminals) launch with a minimal PATH
8+
// that excludes /usr/local/bin, /usr/sbin, etc., causing external CLIs to fail.
9+
if (process.platform !== 'win32') {
10+
const std = ['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'];
11+
const cur = new Set((process.env.PATH ?? '').split(':').filter(Boolean));
12+
for (const p of std) cur.add(p);
13+
process.env.PATH = [...cur].join(':');
14+
}
15+
616
import * as os from 'node:os';
717
import * as path from 'node:path';
818
import { fileURLToPath } from 'node:url';

0 commit comments

Comments
 (0)