[Windows] EEXIST error on mkdir ~/.claude when folder has ReadOnly attribute
Bug
Claude Code intermittently fails with:
API Error: EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude'
The only workaround is /logout + /login, which temporarily fixes it until the token expires again.
Root Cause
On Windows, if the ~/.claude folder has a desktop.ini file (e.g. from a custom folder icon), Windows sets the ReadOnly attribute on the folder. This is normal Windows behavior — the ReadOnly flag on folders is used as a shell extension signal, not to prevent writes.
However, when Claude Code's OAuth token refresh code path calls fs.mkdirSync('~/.claude') without { recursive: true }, Node.js throws EEXIST on Windows when the folder has the ReadOnly attribute, instead of silently succeeding.
The /logout + /login workaround works because it bypasses the token refresh path entirely and provides a fresh token.
Steps to Reproduce
- On Windows, set a custom icon on the
~/.claudefolder (right-click → Properties → Customize → Change Icon), or have any process create adesktop.iniinside it - This causes Windows to set the ReadOnly attribute on the folder
- Wait for the OAuth token to expire
- Next API call triggers token refresh →
EEXISTerror
Suggested Fix
Change fs.mkdirSync(path) to fs.mkdirSync(path, { recursive: true }) in the token refresh / credential write code path. The recursive option is a no-op when the directory already exists, regardless of file attributes.
Workaround
attrib -R "C:\Users\<user>\.claude"
del "C:\Users\<user>\.claude\desktop.ini"
Environment
- Claude Code v2.1.81 (standalone binary)
- Windows 11 Pro 10.0.26200
- Node.js fs.mkdirSync behavior on ReadOnly folders
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗