[BUG] ANTHROPIC_API_KEY in env does not properly override
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [x] Other: Claude Code
- Claude CLI version: 1.0.8 (Claude Code)
- Operating System: macOS 15.5
- Terminal: Wezterm
Bug Description
Setting ANTHROPIC_API_KEY in the terminal before running claude causes claude to prompt you if you want to use the api key. If you say "yes", it will show the override message "Overrides (via env):` at the top in the "Welcome to Claude Code!" card.
The only issue is that, although it says "overrides", the API key is not one in the environment, it's still the one from `/login1, so though it says it's overriding, it's not.
Steps to Reproduce
- Login via
/login - Set an override key in the terminal (
export ANTHROPIC_API_KEY=[new key]) - Run
claude. - Observe that the override message is showing a different key than the one set in the
ANTHROPIC_API_KEYenvironment variable
Expected Behavior
If there is an environment variable $ANTHROPIC_API_KEY set, and you say "yes" when Claude Code prompts you if you want to use it, it should use the override.
Actual Behavior
It makes some indications that the override was noticed, but it doesn't actually apply the override.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗