[BUG] VS Code extension login fails with 400 when CLAUDE_CONFIG_DIR points to a non-default directory (CLI login works)

Status Open
Reported on v2.1.221
Maintainer reply None cached
Activity 0 comments · opened Aug 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

What's wrong?

Logging in through the Claude Code VS Code extension fails after browser authorization when CLAUDE_CONFIG_DIR is set to a non-default directory via the claudeCode.environmentVariables setting. The same account logs in successfully from the terminal CLI with the same variable set.

Two error messages appeared across attempts:

  • Failed to retrieve auth status after login
  • Request failed with status code 400

In both cases the browser authorization step completed normally — the failure happens on return to the extension. No .credentials.json is written and no Keychain entry is updated, so the token exchange appears to fail rather than the authorization itself.

Workaround

Logging in from the terminal with the same variable set works:

CLAUDE_CONFIG_DIR=$HOME/.claude-alt claude
# then /login

After a full restart of VS Code, the extension picks up those credentials and works normally. So only the extension's own login flow is affected.

Environment

  • OS: macOS
  • Claude Code VS Code extension: 2.1.221 (also observed on 2.1.222)
  • Login method: Claude.ai subscription
  • No ANTHROPIC_API_KEY set; no proxy or TLS interception

What Should Happen?

Expected: Login completes; credentials are stored for that config directory.
Actual: Panel returns to the login screen showing Request failed with status code 400.

Error Messages/Logs

Steps to Reproduce

Steps to reproduce

  1. Create a second config directory: mkdir ~/.claude-alt
  2. In VS Code user settings (the setting is machine-scoped, so workspace settings are rejected), add:

``json
"claudeCode.environmentVariables": [
{ "name": "CLAUDE_CONFIG_DIR", "value": "/Users/<user>/.claude-alt" }
]
``

  1. Fully quit and reopen VS Code.
  2. Confirm the variable reaches the spawned process — asking Claude in the panel to run echo "[$CLAUDE_CONFIG_DIR]" correctly returns /Users/<user>/.claude-alt.
  3. Open the Claude Code panel and log in with a Claude.ai subscription account.
  4. Authorize in the browser.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.222

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Additional context

The browser was signed into a different Claude account at the time of the failed attempts, which may be relevant — the authorization code may be bound to the browser's session rather than the account selected in the extension.

Possibly related: #13323, #54787.

View original on GitHub ↗