[BUG] /heapdump fails on Windows with EEXIST when Desktop directory already exists
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
- Open Claude Code on Windows (where ~/Desktop already exists)
- Run /heapdump
- 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗