[BUG] Config save lock fails with EEXIST on Windows — home directory used as lock path, blocking onboarding completion
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?
Claude Code has a broken file-locking mechanism used when saving configuration. When saving config, the CLI attempts to atomically acquire a lock by calling mkdir on the user's home directory path (e.g., C:\Users\ibuchan). Since that directory always exists, every save attempt fails with:
EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
This failure fires silently and repeatedly (~every 100ms) for the entire session. Because config can never be saved, the onboarding completion state (theme selection) is never persisted. On the next launch, the CLI has no record of onboarding completing, so it shows the theme selection again. Pressing Enter to confirm triggers another failed save, and the cycle repeats indefinitely.
The net effect: the user is permanently stuck in the initialization wizard with no error message shown in the UI.
What Should Happen?
The lock mechanism should create a temporary lock file or directory in a location that does not already exist — typically a .lock file alongside the config file, or in a temp directory. On successful config save, the lock should be released. The theme selection should be saved once confirmed and the user should proceed to the next onboarding step (or directly to the CLI prompt if onboarding was already complete).
Error Messages/Logs
2026-03-10T20:09:29.760Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.760Z [DEBUG] MDM settings load completed in 15ms
2026-03-10T20:09:29.769Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.769Z [DEBUG] Broken symlink or missing file encountered for settings.json at path: C:\Users\ibuchan\.claude\settings.local.json
2026-03-10T20:09:29.769Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.769Z [DEBUG] Broken symlink or missing file encountered for settings.json at path: C:\ProgramData\ClaudeCode\managed-settings.json
2026-03-10T20:09:29.770Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.770Z [DEBUG] Broken symlink or missing file encountered for settings.json at path: C:\ProgramData\ClaudeCode\managed-settings.json
2026-03-10T20:09:29.770Z [DEBUG] [init] configureGlobalMTLS starting
2026-03-10T20:09:29.770Z [DEBUG] [init] configureGlobalMTLS complete
2026-03-10T20:09:29.770Z [DEBUG] [init] configureGlobalAgents starting
2026-03-10T20:09:29.770Z [DEBUG] [init] configureGlobalAgents complete
2026-03-10T20:09:29.796Z [DEBUG] Using bash path: "C:\Program Files\Git\bin\bash.exe"
2026-03-10T20:09:29.798Z [DEBUG] Error log sink initialized
2026-03-10T20:09:29.799Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:29.801Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.801Z [DEBUG] Broken symlink or missing file encountered for settings.json at path: C:\ProgramData\ClaudeCode\managed-settings.json
2026-03-10T20:09:29.802Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.802Z [DEBUG] Broken symlink or missing file encountered for settings.json at path: C:\Users\ibuchan\.claude\settings.local.json
2026-03-10T20:09:29.802Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.802Z [DEBUG] Broken symlink or missing file encountered for settings.json at path: C:\ProgramData\ClaudeCode\managed-settings.json
2026-03-10T20:09:29.802Z [DEBUG] [STARTUP] Loading MCP configs...
2026-03-10T20:09:29.804Z [DEBUG] Git remote URL: null
2026-03-10T20:09:29.804Z [DEBUG] No git remote URL found
2026-03-10T20:09:29.804Z [DEBUG] [ToolSearch:optimistic] mode=tst, ENABLE_TOOL_SEARCH=undefined, result=true
2026-03-10T20:09:29.805Z [DEBUG] [STARTUP] Running setup()...
2026-03-10T20:09:29.807Z [DEBUG] detectFileEncoding failed for expected reason: ENOENT
2026-03-10T20:09:29.807Z [DEBUG] Broken symlink or missing file encountered for settings.json at path: C:\ProgramData\ClaudeCode\managed-settings.json
2026-03-10T20:09:29.808Z [DEBUG] Loading skills from: managed=C:\ProgramData\ClaudeCode\.claude\skills, user=C:\Users\ibuchan\.claude\skills, project=[]
2026-03-10T20:09:29.808Z [DEBUG] Error log sink initialized
2026-03-10T20:09:29.825Z [DEBUG] [Claude in Chrome] Found chrome profiles: Default
2026-03-10T20:09:29.826Z [DEBUG] installed_plugins.json doesn't exist, returning empty V2 object
2026-03-10T20:09:29.826Z [DEBUG] Found 0 plugins (0 enabled, 0 disabled)
2026-03-10T20:09:29.829Z [DEBUG] getPluginSkills: Processing 0 enabled plugins
2026-03-10T20:09:29.829Z [DEBUG] Registered 0 hooks from 0 plugins
2026-03-10T20:09:29.830Z [DEBUG] Total plugin skills loaded: 0
2026-03-10T20:09:29.830Z [DEBUG] Total plugin commands loaded: 0
2026-03-10T20:09:29.831Z [DEBUG] Loaded 0 unique skills (0 unconditional, 0 conditional, managed: 0, user: 0, project: 0, additional: 0, legacy commands: 0)
2026-03-10T20:09:29.831Z [DEBUG] getSkills returning: 0 skill dir commands, 0 plugin skills, 5 bundled skills, 0 builtin plugin skills
2026-03-10T20:09:29.836Z [DEBUG] [STARTUP] setup() completed in 31ms
2026-03-10T20:09:29.836Z [DEBUG] [STARTUP] Loading commands and agents...
2026-03-10T20:09:29.837Z [DEBUG] Total plugin agents loaded: 0
2026-03-10T20:09:29.837Z [DEBUG] [STARTUP] Commands and agents loaded in 1ms
2026-03-10T20:09:29.842Z [DEBUG] [STARTUP] Running showSetupScreens()...
2026-03-10T20:09:29.884Z [DEBUG] [keybindings] KeybindingSetup initialized with 104 bindings, 0 warnings
2026-03-10T20:09:29.898Z [DEBUG] [keybindings] Watching for changes to C:\Users\ibuchan\.claude\keybindings.json
2026-03-10T20:09:29.902Z [DEBUG] [Claude in Chrome] Found edge profiles: Default
2026-03-10T20:09:29.903Z [DEBUG] [Claude in Chrome] Extension not found in any browser
2026-03-10T20:09:29.903Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:29.907Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:29.908Z [ERROR] Error: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
at mkdirSync (unknown)
at mkdirSync (B:/~BUN/root/src/entrypoints/cli.js:12:3048)
at d38 (B:/~BUN/root/src/entrypoints/cli.js:6483:5856)
at IA (B:/~BUN/root/src/entrypoints/cli.js:6483:4432)
at CnA (B:/~BUN/root/src/entrypoints/cli.js:4296:584)
at processTicksAndRejections (native:7:39)
2026-03-10T20:09:30.331Z [DEBUG] High write ratio: blit=928, write=1424 (60.5% writes), screen=38x270
2026-03-10T20:09:30.801Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:30.957Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:31.101Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:31.242Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:31.392Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:31.563Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:31.707Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:31.830Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:31.960Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:32.097Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:32.239Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:32.372Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:32.494Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:32.638Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
2026-03-10T20:09:32.758Z [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\ibuchan'
Steps to Reproduce
I haven't been able to get anyone else to reproduce this issue. I've tried reinstalling, different terminals, and using claude code desktop to assist. After it tried everything it could, it sent me here with the attached summaries. The reproduction steps I'm getting from CC are:
- Install Claude Code via winget on Windows 11 (winget install Anthropic.ClaudeCode)
- Ensure the user's home directory exists at C:\Users\<username> (standard Windows setup)
- Launch claude from any terminal (PowerShell, CMD, Git Bash)
- Observe the theme selection screen appears
- Press Enter (or any confirmation key) to select a theme
- Observe: the CLI does not advance — the same screen persists across sessions
- Check C:\Users\<username>\.claude\debug\<latest>.txt — you will see repeated [ERROR] Failed to save config with lock: Error: EEXIST: file already exists, mkdir 'C:\Users\<username>' entries throughout the log
Likely root cause in code: the lock path is being constructed from $HOME or $USER directly rather than deriving a lock path within ~/.claude/ or a temp directory. On Windows, the home directory always pre-exists, so the mkdir-as-lock pattern fails immediately and unconditionally.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
2.1.69
Claude Code Version
2.1.69
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
<img width="676" height="607" alt="Image" src="https://github.com/user-attachments/assets/ef6ba5f8-9cb5-4cea-9903-232fe17de266" />
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗