claude-code - 💡(How to fix) Fix SessionStart hook error: EEXIST when creating plugin data directory

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

SessionStart:startup hook error   Failed to run: EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\plugins\data\claude-mem-thedotmack'

Root Cause

The Claude Code harness creates the plugin data directory (~/.claude/plugins/data/<plugin-name>) on each SessionStart using mkdir without the { recursive: true } option (or -p flag equivalent). Since the directory already exists after the first session, subsequent calls fail with EEXIST.

The fix should be to use mkdirSync(dataDir, { recursive: true }) instead of plain mkdirSync(dataDir) when creating plugin data directories — this is a no-op if the directory already exists.

Code Example

SessionStart:startup hook error   Failed to run: EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\plugins\data\claude-mem-thedotmack'
RAW_BUFFERClick to expand / collapse

Bug Description

On every session start, Claude Code throws a SessionStart hook error because it attempts to create the plugin data directory using mkdir without the recursive flag, causing an EEXIST error when the directory already exists from a previous session.

Error Message

SessionStart:startup hook error   Failed to run: EEXIST: file already exists, mkdir 'C:\Users\<user>\.claude\plugins\data\claude-mem-thedotmack'

Steps to Reproduce

  1. Install the claude-mem plugin from thedotmack
  2. Start a Claude Code session (the plugin data directory is created)
  3. Start any subsequent session
  4. The EEXIST error appears on every session start from that point on

Root Cause

The Claude Code harness creates the plugin data directory (~/.claude/plugins/data/<plugin-name>) on each SessionStart using mkdir without the { recursive: true } option (or -p flag equivalent). Since the directory already exists after the first session, subsequent calls fail with EEXIST.

The fix should be to use mkdirSync(dataDir, { recursive: true }) instead of plain mkdirSync(dataDir) when creating plugin data directories — this is a no-op if the directory already exists.

Environment

  • OS: Windows 11 Pro 10.0.26200
  • Shell: bash (WSL)
  • Plugin: claude-mem@thedotmack v12.3.7

Impact

The error is cosmetic only — the plugin works correctly since the directory already exists in the correct state. However, the repeated error message appears on every session start and is confusing to users.

extent analysis

TL;DR

The issue can be fixed by modifying the mkdir call to include the recursive flag, allowing the directory to be created only if it does not already exist.

Guidance

  • Verify the mkdir call in the Claude Code harness and update it to use mkdirSync(dataDir, { recursive: true }) to prevent the EEXIST error.
  • Check the plugin data directory creation logic to ensure it handles existing directories correctly.
  • Consider adding error handling to ignore EEXIST errors when creating the plugin data directory, as the directory already exists and the plugin works correctly.
  • Test the updated code to ensure the error message no longer appears on subsequent session starts.

Example

const fs = require('fs');
const dataDir = 'C:\\Users\\<user>\\.claude\\plugins\\data\\claude-mem-thedotmack';
fs.mkdirSync(dataDir, { recursive: true });

Notes

The fix assumes that the mkdirSync function is used to create the plugin data directory. If a different function or method is used, the fix may need to be adjusted accordingly.

Recommendation

Apply the workaround by updating the mkdir call to include the recursive flag, as this will prevent the EEXIST error and ensure the plugin data directory is created correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix SessionStart hook error: EEXIST when creating plugin data directory