claude-code - 💡(How to fix) Fix CLAUDE_CONFIG_DIR not respected by VS Code shell-integration lock files [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#56370Fetched 2026-05-06 06:29:55
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Root Cause

Users who keep ~/ on a small SSD and move config to a larger / synced drive (Dropbox, Syncthing, secondary disk) end up with split state: most data on the configured path, but a stray ~/.claude/ subtree with junk locks that they can't clean up because it regenerates. It also makes documentation harder ("set CLAUDE_CONFIG_DIR and you're done" — except for this one path).

Fix Action

Workaround

A directory junction makes the hardcoded path resolve to the configured one:

# from any PowerShell (Developer Mode / admin not required for /J)
New-Item -Path "$env:USERPROFILE\.claude" -ItemType Directory -Force | Out-Null
cmd /c "mklink /J $env:USERPROFILE\.claude\ide D:\claude\ide"

After this, locks created at ~/.claude/ide/<port>.lock physically land in D:\claude\ide\<port>.lock. Functional, but a workaround — CLAUDE_CONFIG_DIR should cover this path natively.

Code Example

[Environment]::SetEnvironmentVariable("CLAUDE_CONFIG_DIR", "D:\claude", "User")

---

# from any PowerShell (Developer Mode / admin not required for /J)
New-Item -Path "$env:USERPROFILE\.claude" -ItemType Directory -Force | Out-Null
cmd /c "mklink /J $env:USERPROFILE\.claude\ide D:\claude\ide"
RAW_BUFFERClick to expand / collapse

Environment

  • OS: Windows 11 Pro 26200
  • Shell: PowerShell 5.1 inside VS Code integrated terminal
  • Claude Code: native install (CLI only, no separate IDE extension installed)
  • Config dir override: CLAUDE_CONFIG_DIR=D:\claude (set permanently via user environment variables)

Observed behaviour

CLAUDE_CONFIG_DIR is honoured for almost everything:

  • agents/, agent-memory/, skills/, settings.json, CLAUDE.md, hooks/, templates/, plugins/, projects/, history.jsonl, commands/, tasks/, sessions/, telemetry/ — all live under D:\claude\ and are read/written there correctly.

But the VS Code shell-integration lock files are written to the hardcoded path:

  • %USERPROFILE%\.claude\ide\<port>.lock

even when CLAUDE_CONFIG_DIR=D:\claude is set. Result: D:\claude\ide\ stays empty, while a phantom %USERPROFILE%\.claude\ directory keeps reappearing with a single ide/ subfolder full of stale locks.

Reproduction

  1. Set CLAUDE_CONFIG_DIR to a non-default path on Windows:
    [Environment]::SetEnvironmentVariable("CLAUDE_CONFIG_DIR", "D:\claude", "User")
  2. Restart shell. Confirm with echo $env:CLAUDE_CONFIG_DIRD:\claude.
  3. Delete or rename %USERPROFILE%\.claude\.
  4. Open a new PowerShell terminal inside VS Code (so the CLI auto-detects VS Code shell integration).
  5. Run any Claude Code command (e.g. claude startup, or send a prompt).
  6. Inspect %USERPROFILE%\.claude\ide\ — it contains a freshly-written <port>.lock file.
  7. D:\claude\ide\ remains empty.

Expected behaviour

Lock files for VS Code shell integration should be written to ${CLAUDE_CONFIG_DIR}/ide/ when the variable is set, falling back to %USERPROFILE%\.claude\ide\ only when it isn't.

Workaround

A directory junction makes the hardcoded path resolve to the configured one:

# from any PowerShell (Developer Mode / admin not required for /J)
New-Item -Path "$env:USERPROFILE\.claude" -ItemType Directory -Force | Out-Null
cmd /c "mklink /J $env:USERPROFILE\.claude\ide D:\claude\ide"

After this, locks created at ~/.claude/ide/<port>.lock physically land in D:\claude\ide\<port>.lock. Functional, but a workaround — CLAUDE_CONFIG_DIR should cover this path natively.

Why it matters

Users who keep ~/ on a small SSD and move config to a larger / synced drive (Dropbox, Syncthing, secondary disk) end up with split state: most data on the configured path, but a stray ~/.claude/ subtree with junk locks that they can't clean up because it regenerates. It also makes documentation harder ("set CLAUDE_CONFIG_DIR and you're done" — except for this one path).

Likely fix location

The path is probably hardcoded in the VS Code shell-integration / IDE-detection module. The fix is a one-liner: change Path.home() / ".claude" / "ide" (or similar) to config_dir() / "ide" where config_dir() is the same helper used elsewhere in the codebase.

extent analysis

TL;DR

The most likely fix is to update the VS Code shell-integration module to use the CLAUDE_CONFIG_DIR environment variable for determining the lock file path.

Guidance

  • The issue is likely caused by a hardcoded path in the VS Code shell-integration module, which can be fixed by changing the path to use the config_dir() helper function.
  • To verify the fix, set CLAUDE_CONFIG_DIR to a non-default path, restart the shell, and run a Claude Code command to check if the lock files are written to the correct location.
  • As a temporary workaround, creating a directory junction can redirect the hardcoded path to the configured one, but this is not a native solution.
  • The fix should be applied to the VS Code shell-integration module, specifically where the Path.home() / ".claude" / "ide" path is used.

Example

No code snippet is provided as the exact fix location and code are not specified in the issue.

Notes

The provided workaround using a directory junction is functional but not a native solution, and the fix should be applied to the VS Code shell-integration module to use the CLAUDE_CONFIG_DIR environment variable.

Recommendation

Apply the workaround using a directory junction until the native fix is implemented, as it provides a functional solution to the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix CLAUDE_CONFIG_DIR not respected by VS Code shell-integration lock files [1 comments, 2 participants]