[BUG] /heapdump fails on Windows with EEXIST when Desktop directory already exists

Resolved 💬 3 comments Opened Mar 12, 2026 by andrei-geminus Closed Mar 16, 2026

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?

Running the /heapdump slash command fails immediately with:

Failed to create heap dump: EEXIST: file already exists, mkdir 'C:\Users\<user>\Desktop'

The command attempts to mkdir the Desktop directory, which already exists on any normal Windows installation. It appears the heapdump logic doesn't use a recursive/{ recursive: true }
mkdir or doesn't check for directory existence before creating it.

What Should Happen?

/heapdump should successfully write a heap dump file to the Desktop (or another target directory), handling the case where the directory already exists.

Error Messages/Logs

Failed to create heap dump: EEXIST: file already exists, mkdir 'C:\Users\<user>\Desktop'

Steps to Reproduce

  1. Open Claude Code on Windows (where ~/Desktop already exists)
  2. Run /heapdump
  3. Observe the EEXIST error

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.74

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

Likely fix: change fs.mkdirSync(desktopPath) to fs.mkdirSync(desktopPath, { recursive: true }), which is a no-op when the directory exists.

View original on GitHub ↗

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