[Windows] EEXIST error on mkdir ~/.claude when folder has ReadOnly attribute

Resolved 💬 3 comments Opened Mar 22, 2026 by seanGSISG Closed Mar 25, 2026

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

  1. On Windows, set a custom icon on the ~/.claude folder (right-click → Properties → Customize → Change Icon), or have any process create a desktop.ini inside it
  2. This causes Windows to set the ReadOnly attribute on the folder
  3. Wait for the OAuth token to expire
  4. Next API call triggers token refresh → EEXIST error

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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗