Forward login-shell env vars (bashrc/zshrc exports) to harness children - #330
Open
labkita7 wants to merge 1 commit into
Open
Forward login-shell env vars (bashrc/zshrc exports) to harness children#330labkita7 wants to merge 1 commit into
labkita7 wants to merge 1 commit into
Conversation
GUI/service launches never run shell init, so the login-shell snapshot is the daemon's only view of the user's environment — but it kept only the PATH, dropping every other export. Provider CLIs (pi-acp and the rest) that read custom variables configured in ~/.bashrc or ~/.zshrc (API keys, base URLs, proxies) therefore failed under the headed app. The snapshot now keeps the full environment between the markers and compose_path forwards variables the daemon's own env doesn't already define (explicit process env always wins; shell bookkeeping and the probe's own markers are never forwarded). ZERON_NO_LOGIN_SHELL_ENV=1 opts out while keeping the PATH composition. Co-authored-by: fajar sidik <jardik.oryza@gmail.com>
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 zeron runs as a headed app (Dock/Finder/launchd/systemd), the daemon never runs shell init, so harness children inherit a minimal environment. The login-shell snapshot (
crates/harness/src/shell_env.rs) already fixes PATH resolution — but it kept only PATH and dropped every other export. Provider CLIs behind the harnesses (pi viapi-acp, and the rest) that read custom variables configured in~/.bashrc/~/.zshrc— API keys, base URLs, proxy settings — therefore failed even though the same CLIs work fine from the user's terminal.Fix
LoginShellEnv { path, vars }), with the same hostile-init defenses (last-begin-marker parse, PATH-presence validity gate, probe-marker drop).compose_path— the single choke point every harness child spawn goes through (pi/ACP, Claude, Codex, Cursor, opencode, npm adapter installs, engine git/gh) — now also forwards snapshot variables the daemon's own environment doesn't already define. Explicit process env always wins;PWD/OLDPWD/SHLVL/_and the probe's ownZERON_RESOLVING_ENVIRONMENT/TERM=dumbpairs are never forwarded.ZERON_NO_LOGIN_SHELL_ENV=1opts out of variable forwarding while keeping the PATH composition (ZERON_NO_LOGIN_SHELL=1still disables the snapshot entirely).Verification
cargo test -p zeron-harness --tests: 13 test binaries, 207 passed, 0 failed (10 ignored real-lifecycle tests by design).shell_env_resolutione2e: a var exported by the fake login shell reaches a spawned child command, an existing process var is not overridden, the probe marker never leaks.cargo fmt --checkclean for the touched files; remaining clippy/fmt findings in the crate are pre-existing onmain(unrelated files, not touched here).Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.