-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: inherit shell environment for Claude Code CLI authentication #8323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -191,6 +191,12 @@ function runProcess({ | |||||
| process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS || | ||||||
| CLAUDE_CODE_DEFAULT_MAX_OUTPUT_TOKENS.toString(), | ||||||
| }, | ||||||
| // IMPORTANT: These options are critical for Claude CLI authentication | ||||||
| // extendEnv: true - Inherits parent process environment variables including ANTHROPIC_API_KEY | ||||||
| // shell: true - Ensures proper environment variable expansion for authentication tokens | ||||||
| // Without these, Claude CLI fails with "Invalid API key" even when properly authenticated | ||||||
| extendEnv: true, | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2 (Medium) — |
||||||
| shell: true, | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1 (High) — Enabling
Suggested change
|
||||||
| cwd, | ||||||
| maxBuffer: 1024 * 1024 * 1000, | ||||||
| timeout: CLAUDE_CODE_TIMEOUT, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 (Medium) — This test asserts implementation detail (
shell: true) rather than behavior. Prefer asserting that the child process receives the needed secrets from the environment (e.g., ANTHROPIC_API_KEY). This will keep the test robust if we later removeshellfor security.