Files
orca/src/shared/system-cli-install-dirs.ts
T
Hyein ChoandNeil 48f7ce7fed feat(terminal): seed MacPorts /opt/local on PATH when port is installed (#20146)
Packaged macOS builds now append /opt/local/bin and /opt/local/sbin to the
seeded PATH when the default-prefix `port` binary exists, and the agent CLI
install-dir fallback also checks /opt/local/bin. Both are appended last so
existing Homebrew/system resolutions never change.

Co-authored-by: Neil <neil@stably.ai>
2026-10-27 20:24:47 -07:00

39 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { join } from 'node:path'
/** Lookup-only fallback: prepending system dirs to inherited PATH would reorder the user’s binaries (#18234).
* Keep system-block order aligned with patchPackagedProcessPath/POSIX_VERSION_MANAGER_BIN_DIRS; cross-block precedence differs
* for ~/.local/bin, which precedes this fallback but follows seeded system dirs. Do not hoist system paths above version managers.
* Omit sbin/~/bin and off-darwin /opt/homebrew; Linuxbrew has its own prefix. Include installer-owned .opencode/.vite-plus (#829) and .grok (#17590) bins.
* Exception: a newly discovered CLI with sibling node may prepend that dir only to its child PATH for runtime pairing (#10932). */
export function getSystemCliInstallDirectories(
platform: NodeJS.Platform,
homePath: string
): string[] {
// Both lookup and seeded system blocks cover POSIX only; Windows installer paths remain outside this fallback.
if (platform === 'win32') {
return []
}
const directories: string[] = []
if (platform === 'darwin') {
// Apple Silicon Homebrew; Intel Homebrew shares /usr/local with npm's prefix.
directories.push('/opt/homebrew/bin')
}
directories.push('/usr/local/bin')
if (platform === 'linux') {
// Avoid phantom snap/Linuxbrew probes off Linux, matching seeded PATH.
directories.push('/snap/bin', '/home/linuxbrew/.linuxbrew/bin')
}
directories.push(
'/nix/var/nix/profiles/default/bin',
join(homePath, '.nix-profile', 'bin'),
join(homePath, '.opencode', 'bin'),
join(homePath, '.vite-plus', 'bin'),
join(homePath, '.grok', 'bin')
)
if (platform === 'darwin') {
// MacPorts last, matching the seed; ungated since a lookup miss costs the same stat as the seed's `port` gate.
directories.push('/opt/local/bin')
}
return directories
}