-
Notifications
You must be signed in to change notification settings - Fork 413
Closed
Description
Problem
When calling external CLIs (like opencode), child processes may not find system commands like sysctl because the PATH environment variable does not include standard system paths.
This causes errors like:
error: Executable not found in $PATH: "sysctl"
Solution
Add standard paths to the environment when spawning external CLI processes:
// src/external.ts
const standardPath = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin';
const env = {
...process.env,
PATH: `${process.env.PATH}:${standardPath}`,
};
const result = spawnSync(cli.binary, args, { stdio: 'inherit', env });Test Case
# Register opencode
opencli register opencode --binary /usr/local/bin/opencode --desc "OpenCode AI coding agent"
# Before fix: fails with sysctl not found
opencli opencode --version
# After fix: works correctly
opencli opencode --version
# Output: 1.2.20I've already implemented this fix locally and it works. Happy to submit a PR if needed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels