-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
App Version
3.25.17
API Provider
Not Applicable / Other
Model Used
Claude Code
Roo Code Task Links (Optional)
Title: Bug: Extension Fails for Subscription Users if ANTHROPIC_API_KEY is set
Description
When the extension is correctly configured to use Claude Code as the API Provider, it fails if an ANTHROPIC_API_KEY environment variable is present in the user's shell environment.
This leads to a confusing Credit balance is too low error for users with Claude Max/Pro subscriptions. They have correctly set up the extension to use their local CLI (to leverage their flat-rate subscription), but an old, lingering API key from a separate pay-as-you-go account intercepts the authentication and causes the failure.
This makes the extension seem broken even when the user has configured it perfectly according to its own settings.
Steps to Reproduce
-
Have an active Claude Max or Pro subscription.
-
Install the
claude codeCLI and log in successfully using your subscription account (/login). -
In your shell profile (e.g.,
~/.zshrc), set anANTHROPIC_API_KEYenvironment variable from a separate, pay-as-you-go Console account that has a zero-dollar balance. -
Load the environment variable in your shell (
source ~/.zshrc). -
In the Cline/Roo Code extension settings, set the API Provider to
Claude Codeand ensure the Claude Code CLI Path points to your local installation. -
Attempt to run any command through the extension's UI.
Expected Behavior
Since the API Provider is set to Claude Code, the extension should successfully use the CLI's active subscription-based login (claudeai method). It should either ignore the ANTHROPIC_API_KEY environment variable or warn the user about the potential conflict.
Actual Behavior
The extension's background call to the claude code CLI prioritizes the ANTHROPIC_API_KEY environment variable. This results in an API call using the old, unfunded account, which is immediately rejected.
The user sees the error: Command failed with exit code 1: ... Credit balance is too low.
Root Cause Analysis
The claude code CLI has different authentication pathways for interactive use versus non-interactive/SDK use (which the extension uses via the -p flag). The non-interactive mode defaults to using the ANTHROPIC_API_KEY if it is set, bypassing the user's interactive subscription login. This makes the extension's "API Provider" setting fail silently.
Workaround / Solution
The issue was successfully resolved by performing the following step:
- Removing the Environment Variable: Manually removing the
export ANTHROPIC_API_KEY="..."line from the user's shell profile (~/.zshrc).
Proposed Solutions for the Extension
This issue creates a very poor user experience for legitimate subscription customers. The extension could help mitigate this significantly:
- High Priority - Detection and Warning: On startup, the extension should check
process.env.ANTHROPIC_API_KEY. If the key is set and the API Provider is set toClaude Code, the extension must show a prominent VS Code warning notification. The warning should state: "AnANTHROPIC_API_KEYenvironment variable was detected. This may conflict with your subscription login and cause errors. Please unset it to ensure your Claude Max/Pro plan is used." - Documentation: Add a section to the README specifically for Claude Max/Pro users, instructing them to ensure
ANTHROPIC_API_KEYis not set in their environment.
Thank you for the excellent tool. Addressing this conflict will greatly improve the experience for subscription users.
π Steps to Reproduce
.
π₯ Outcome Summary
.
π Relevant Logs or Errors (Optional)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status