fix(acp): pass HOME and Anthropic env vars to child process (#3135)#3148
Merged
Conversation
The ACP spawn environment only passed PATH, TMPDIR, TEMP, TMP to the claude-agent-acp child process. Missing HOME meant os.homedir() couldn't find ~/.claude/credentials, and missing ANTHROPIC_* / CLAUDE_* env vars meant the child couldn't authenticate with the Anthropic API. This caused sessions to silently fail — child process starts but session/new times out because CC can't connect to Anthropic. Now passes through: - HOME, USER, SHELL, LANG, LC_ALL, LC_CTYPE - All ANTHROPIC_* and CLAUDE_* prefixed env vars
c8d1847 to
20dedaa
Compare
3 tasks
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
Issue #3135: ACP child process (
claude-agent-acp) receives only 3 env vars:PATH,TMPDIR,NO_COLOR. MissingHOMEmeans it can't find~/.claude/credentials. MissingANTHROPIC_*/CLAUDE_*means it can't authenticate with the Anthropic API.The child process starts, the JSON-RPC handshake completes, but
session/newtimes out because CC can't connect to Anthropic. Sessions appearidlebutclaudeRunning: falseandclaudeSessionId: null.Root Cause
buildAcpSpawnEnv()insrc/acp-spawn-env.tsconstructs a minimal environment with only PATH and temp dirs. Everything else fromprocess.envis filtered out.Fix
Pass through essential env vars to the ACP child process:
HOME,USER,SHELL,LANG,LC_ALL,LC_CTYPE(system essentials)ANTHROPIC_*prefixed vars (API keys, endpoints)CLAUDE_*prefixed vars (config dir, executable path)Before
After
Files
src/acp-spawn-env.ts: expandcopyPlatformExecutionEnvto include HOME and auth-related env vars