[BUG] EEXIST: file already exists, mkdir '~/.claude' on every prompt (Windows)
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?
Every prompt entered in Claude Code fails with the following error:
API Error: EEXIST: file already exists, mkdir 'C:\Users\<username>\.claude'
The error occurs immediately on startup and blocks all usage.
Steps to reproduce:
Install Claude Code on Windows
Open Claude Code CLI
Type any prompt and press Enter
Expected behavior:
Claude Code starts normally and processes the prompt.
Actual behavior:
Every prompt results in EEXIST: file already exists, mkdir 'C:\Users\<username>\.claude'. The directory already exists but Claude Code tries to create it again without checking.
Environment:
OS: Windows
Claude Code version: 2.1.173
Node.js version: (bitte ergänzen)
Root cause (suspected):
The mkdir call for ~/.claude is missing the { recursive: true } option. On Windows, Node.js throws EEXIST when trying to create a directory that already exists, instead of silently succeeding. Using fs.mkdir(path, { recursive: true }) or fs.mkdirSync(path, { recursive: true }) would fix this.
Workaround:
Running attrib -R %USERPROFILE%\.claude /S /D in an elevated PowerShell removes the ReadOnly attribute and resolves the issue temporarily.
Related issues: #31030, #27791, #31185
What Should Happen?
Claude Code should start normally and process inputs without throwing an error. The mkdir call for ~/.claude should use the { recursive: true } option, so that the program continues silently if the directory already exists — just as it works on other operating systems. After entering a question or command, Claude Code should return a normal response instead of crashing with EEXIST.
Error Messages/Logs
API Error: EEXIST: file already exists, mkdir 'C:\Users\Unsername\.claude'
Steps to Reproduce
Claude Code auf Windows installieren
Claude Code CLI öffnen
Warten bis Claude Code gestartet ist
Eine beliebige Eingabe tippen und Enter drücken
Der Fehler erscheint sofort — Claude Code liefert keine Antwort
Jede weitere Eingabe führt zum gleichen Fehler
Ein Neustart von Claude Code behebt das Problem nicht
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude Code version: 2.1.173
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_