[BUG] VS Code extension ignores CLAUDE_CONFIG_DIR environment variable
Status Open
Reported on v2.1.63
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 15 comments · opened Mar 3, 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?
The VS Code extension does not respect the CLAUDE_CONFIG_DIR environment variable, even when set via claudeCode.environmentVariables in VS Code settings or when launching VS Code from a shell where the variable is exported.
The CLI correctly uses CLAUDE_CONFIG_DIR to support multiple profiles/accounts, but the extension always reads from and writes to ~/.claude/ regardless of configuration.
What Should Happen?
The extension should respect CLAUDE_CONFIG_DIR the same way the CLI does, allowing users to maintain separate configurations (e.g., work vs personal accounts) per VS Code profile.
Error Messages/Logs
Steps to Reproduce
- Create a custom config directory (e.g.,
~/.claude-personal) - Set
CLAUDE_CONFIG_DIRvia one of:
claudeCode.environmentVariablesin VS Code settings:
"claudeCode.environmentVariables": [
{ "name": "CLAUDE_CONFIG_DIR", "value": "/path/to/.claude-personal" }
]
- Exporting the variable before launching VS Code:
export CLAUDE_CONFIG_DIR="$HOME/.claude-personal"
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code
- Open the Claude Code extension
- Observe that the extension prompts for login and creates files in
~/.claude/instead of the configured directory
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.63
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Related Issues
- #261 - Added
CLAUDE_CONFIG_DIRsupport for CLI - #4739 -
/idecommand fails whenCLAUDE_CONFIG_DIRis set (locked) - #24963 - Support for multiple accounts/profiles
Environment
- VS Code Version: 1.109.5 (arm64)
Showing cached comments. Read the full discussion on GitHub ↗
12 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is not a duplicate of the listed issues:
#4739 is locked and cannot be commented on
#12719 and #4739 focus specifically on /ide command failure
This issue is broader: the VS Code extension ignores CLAUDE_CONFIG_DIR entirely (auth, config, credentials), not just for IDE detection
The root cause may be related, but the scope and impact are different.
+1, as for me:
Is this a regression?
Yes, I was using this workaround as a bash variable until last month
Root cause analysis (Extension v2.1.70)
I traced the session listing through the minified
extension.jsand found the exact call chain:listSessions()→oP({dir: this.cwd})→ve()→es(dir)es()→ps(dir)→path.join(MU(), hashedDir)MU()=path.join(IG(), "projects")IG()=process.env.CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), ".claude")IG()correctly readsprocess.env.CLAUDE_CONFIG_DIR— but the extension host process never receives this variable:terminal.integrated.env.osxonly applies to terminal processes, not the extension hostclaudeCode.claudeProcessWrapperonly takes effect when spawning the Claude CLI process, not when the extension itself lists sessionsclaudeCode.environmentVariablesalso doesn't propagate to the extension host's ownprocess.envSo the Claude process runs correctly with the custom config dir (via the wrapper), but the session picker UI always reads from
~/.claude.Workaround
Close all VSCode instances, then launch from terminal:
This way the extension host inherits the variable. Does not work if another VSCode instance is already running (merges into existing instance).
Suggested fix
Add a
claudeCode.configDirsetting that the extension reads for both spawning the Claude process and its own internal operations (session listing, plans, file history). This would make all existing env-based workarounds unnecessary.Also affects plugins (
installed_plugins.json) — not just VS Code extension.When using
CLAUDE_CONFIG_DIRto separate work vs personal accounts, plugins installed for one account still show up on the other account because~/.claude/plugins/is hardcoded.The
/mcpdialog shows them as "needs authentication" on the wrong account — harmless but noisy. There's no per-account plugin scoping.Related closed issues: #972, #15071
When will this be fixed?
I would also like this to be fixed
Adding my +1 for this. I need to be able to separate my work & personal Claude accounts on the same computer. For now, I'm overriding VS Code startup script to give VS Code a fake home folder when starting up (one for work, one for personal). This works, but it comes with the symptom of having anything external that's executed from VS Code use that fake home folder (ie. opening a browser link is like I'm opening the browser for the first time).
Still not fixed?
EDIT (corrected): the test below verifies only the spawned agent path. The extension host still ignores
CLAUDE_CONFIG_DIRon Windows (session list/switch,settings.json, MCP/plugin persistence all default to~/.claude), so this is not macOS-only or fixed — the host-side half of this issue still reproduces. See my follow-up below and @pasrom's root-cause analysis. Original kept for context.---
Windows 11: works via the
claudeCode.environmentVariablessetting (ext 2.1.178)On Win 11 (extension 2.1.178, CLI 2.1.177) the
claudeCode.environmentVariablessetting does point the spawned Claude session at a non-defaultCLAUDE_CONFIG_DIR:To rule out a leaked shell variable, I opened the repo in a throwaway instance (
code --new-window --user-data-dir <temp> <repo>) with noCLAUDE_CONFIG_DIRin the environment and a fresh profile;/statusthen came up under the account in the custom dir, not~/.claude. The setting was the only possible source.Since the issue is labeled
platform:macosand the report was on 2.1.63, this suggests the bug is macOS-specific and/or was (partly) fixed by 2.1.178 — might be worth a maintainer scoping. (I only verified the setting path, not the shell-export path.)@kdsrc this only partially works. I am also on Windows 11, though using WSL.
Correcting my comment above: on Windows 11 (ext 2.1.181)
claudeCode.environmentVariablesonly reaches the spawned Claude CLI, not the extension host. The agent ends up on the right account, but everything the host does - session-history list,settings.json, MCP/plugin install & persistence (.claude.json), file-history, plans - readsprocess.env.CLAUDE_CONFIG_DIRfrom the host process, which never receives it and falls back to~/.claude. That host-side half is the core of this issue, still reproducing on Windows - and it's why older sessions open empty and plugins/MCP don't persist across sessions.The fix is small, and it's the one already proposed in this thread: a
claudeCode.configDirsetting the extension reads for both the spawned process and its own host-side operations. Give the host process the right config dir and all of the above bind to the correct account.I've verified that it works: a small VS Code extension that gives the extension host the correct config dir resolves history, settings and MCP/plugin state, with no change to the agent path. So the host side is genuinely a one-setting fix. Happy to share details if useful - feel free to reach out.