Documentation
¶
Overview ¶
Package shellenv resolves the user's login-shell PATH into the running process, fixing the classic macOS/Linux problem where a GUI app launched from Finder/Dock/Spotlight inherits only launchd's minimal PATH (/usr/bin:/bin:/usr/sbin:/sbin) and cannot find user-installed tools (Homebrew, bun, npm-global, nvm/volta-managed node, …).
Mechanism (mirrors VS Code's src/vs/platform/shell/node/shellEnv.ts): spawn the user's login+interactive shell, ask it to dump its env, parse the PATH out. We do NOT read or parse .zshrc/.zprofile ourselves — the shell is the only correct interpreter of its own config (source chains, conditionals, functions). We borrow the shell's brain, we don't act as a parser. Only PATH is touched; other vars stay untouched to avoid breaking the app (e.g. NODE_OPTIONS).
Idempotent per process: sync.Once guards the work so only the first caller spawns a shell; later callers get the cached result (or cached error) instantly. Two call sites (harness.Discover path + harness spawn path) thus never double-spawn — whoever needs PATH first wins, the other no-ops.
Windows is a no-op (env vars are global via the registry, no per-shell PATH).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Resolve ¶
Resolve merges the user's login-shell PATH into the current process. Idempotent: the first call spawns the shell and caches the outcome; all subsequent calls return instantly with the same result. Returns nil on Windows (no-op) and on success. On failure PATH is left untouched and a non-nil error is returned (caller should log and continue — the app still runs, just with the minimal PATH).
The ctx is accepted for API symmetry but is NOT used to cancel the resolve work. The work runs under a fixed internal budget (resolveBudget) and its result is cached process-wide via sync.Once; allowing a caller to abort it would risk poisoning the shared cache with a premature failure that later callers (with a long-lived ctx) would inherit forever. All callers therefore wait for the work to finish (bounded by resolveBudget) on the first call.
Types ¶
This section is empty.