fix: ensure standard PATH is available for external CLIs#285
Merged
jackwener merged 1 commit intojackwener:mainfrom Mar 23, 2026
Merged
fix: ensure standard PATH is available for external CLIs#285jackwener merged 1 commit intojackwener:mainfrom
jackwener merged 1 commit intojackwener:mainfrom
Conversation
Astro-Han
reviewed
Mar 23, 2026
Contributor
Astro-Han
left a comment
There was a problem hiding this comment.
Good fix for a real problem — sysctl not found makes sense when PATH is stripped. Two things to watch for:
process.env.PATH can be undefined
If PATH is unset, the template string produces "undefined:/usr/local/bin:..." — a literal undefined directory in the search path. A quick guard:
const currentPath = process.env.PATH || '';isBinaryInstalled() uses a different PATH
The new env is only passed to spawnSync, but isBinaryInstalled() (line 68, uses which) still runs with the original process.env. If a binary exists only in a standard path like /usr/sbin, isBinaryInstalled returns false while spawnSync would find it — leading to unnecessary install prompts.
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 jackwener#284
421a6e4 to
2da2ef3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When calling external CLIs (like
opencode), child processes may not find system commands likesysctlbecause the PATH environment variable does not include standard system paths.This causes errors like:
Solution
Add standard paths to the environment when spawning external CLI processes.
Test Case
Fixes #284