claude-code - 💡(How to fix) Fix EBUSY: concurrent instances race on .claude.json (Windows) [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#46481Fetched 2026-04-11 06:19:10
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1cross-referenced ×1

Running multiple Claude Code instances simultaneously on Windows causes EBUSY: resource busy or locked errors when writing to ~/.claude.json. The file is 72KB and written with writeFileSync without file locking, so concurrent instances race on it.

Error Message

ERROR EBUSY: resource busy or locked, open 'C:\Users<user>.claude.json'

Root Cause

Windows file locks are mandatory (unlike Unix advisory locks), so writeFileSync from one process blocks/fails when another process has the file open. A write-to-temp-then-rename pattern or proper file locking would fix this.

Code Example

ERROR EBUSY: resource busy or locked, open 'C:\Users\<user>\.claude.json'

  at writeFileSync (unknown)
  VZ8 (B:/~BUN/root/src/entrypoints/cli.js:135:1271)
  NcK (B:/~BUN/root/src/entrypoints/cli.js:442:23227)
  p6 (B:/~BUN/root/src/entrypoints/cli.js:442:21289)
  <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:8305:475)
  Au (B:/~BUN/root/src/entrypoints/cli.js:492:63164)
  zm8 (B:/~BUN/root/src/entrypoints/cli.js:492:76228)
  dR (B:/~BUN/root/src/entrypoints/cli.js:492:76109)
  zm8 (B:/~BUN/root/src/entrypoints/cli.js:492:77018)
  dR (B:/~BUN/root/src/entrypoints/cli.js:492:76109)
RAW_BUFFERClick to expand / collapse

Summary

Running multiple Claude Code instances simultaneously on Windows causes EBUSY: resource busy or locked errors when writing to ~/.claude.json. The file is 72KB and written with writeFileSync without file locking, so concurrent instances race on it.

Reproduction

  1. Open two Claude Code sessions (e.g., terminal + desktop app, or two terminals)
  2. Use both actively
  3. One will eventually hit:
ERROR EBUSY: resource busy or locked, open 'C:\Users\<user>\.claude.json'

  at writeFileSync (unknown)
  VZ8 (B:/~BUN/root/src/entrypoints/cli.js:135:1271)
  NcK (B:/~BUN/root/src/entrypoints/cli.js:442:23227)
  p6 (B:/~BUN/root/src/entrypoints/cli.js:442:21289)
  <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:8305:475)
  Au (B:/~BUN/root/src/entrypoints/cli.js:492:63164)
  zm8 (B:/~BUN/root/src/entrypoints/cli.js:492:76228)
  dR (B:/~BUN/root/src/entrypoints/cli.js:492:76109)
  zm8 (B:/~BUN/root/src/entrypoints/cli.js:492:77018)
  dR (B:/~BUN/root/src/entrypoints/cli.js:492:76109)

Root cause

Windows file locks are mandatory (unlike Unix advisory locks), so writeFileSync from one process blocks/fails when another process has the file open. A write-to-temp-then-rename pattern or proper file locking would fix this.

Environment

  • Windows 11 Pro 10.0.26200
  • Claude Code (latest as of 2026-04-10)

Filed by Jeff Yaw, Yaw Labs ([email protected])

extent analysis

TL;DR

Implementing a write-to-temp-then-rename pattern or proper file locking can resolve the EBUSY: resource busy or locked errors when writing to ~/.claude.json.

Guidance

  • Consider using a temporary file for writing and then renaming it to ~/.claude.json to avoid concurrent access issues.
  • Implement proper file locking mechanisms to prevent multiple processes from accessing the file simultaneously.
  • Review the writeFileSync function calls to ensure they are properly synchronized across multiple instances of Claude Code.
  • Evaluate the feasibility of using a more robust storage solution that supports concurrent access, such as a database.

Example

const temp = require('temp');
const fs = require('fs');

// Create a temporary file
const tmpFile = temp.path({ suffix: '.json' });

// Write to the temporary file
fs.writeFileSync(tmpFile, jsonData);

// Rename the temporary file to the target file
fs.renameSync(tmpFile, '~/.claude.json');

Notes

The provided solution assumes that the writeFileSync function is the primary cause of the issue. However, other factors, such as the underlying file system or operating system configuration, may also contribute to the problem.

Recommendation

Apply a workaround by implementing a write-to-temp-then-rename pattern, as this approach can be implemented without modifying the underlying file locking mechanisms.

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