[BUG] `/heapdump` command fails when the working directory is `C:\Users\<user>\Desktop` (or any existing directory).

Resolved 💬 3 comments Opened Mar 10, 2026 by xliry Closed Mar 14, 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?

/heapdump command fails with EEXIST: file already exists error when the working directory is an existing path (e.g.
C:\Users\<user>\Desktop). It tries to mkdir the current working directory itself instead of creating a subdirectory or
file within it.

What Should Happen?

/heapdump should create a heap dump file (or subdirectory) inside the current working directory, not attempt to create
the working directory itself.

Error Messages/Logs

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

Steps to Reproduce

  1. Open Claude Code from Desktop (or any existing directory)

cd ~/Desktop && claude

  1. Wait until memory usage is high, or just run /heapdump immediately
  2. Error appears: "Failed to create heap dump: EEXIST: file already exists, mkdir 'C:\Users\<user>\Desktop'"

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

v2.1.72

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Was trying to diagnose high memory usage (3.1GB) when this error occurred. The issue seems to be that the heapdump
code calls mkdir on the output path without checking if it already exists, or is using the working directory path
directly instead of a subdirectory path.

View original on GitHub ↗

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