Windows corporate environment: Infinite EPERM retry loop with SessionStart hooks

Resolved 💬 3 comments Opened Nov 13, 2025 by PedroGiudice Closed Nov 16, 2025

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?

Environment

  • OS: Windows 10/11 (corporate environment with GPO policies)
  • Claude Code CLI: v2.0.31
  • User: Administrator
  • Location: C:\Users\[corporate-user]\.claude.json

Root Cause

Corporate GPO policies block creation of .claude.json.lock directory → EPERM error

CLI behavior:

  1. Attempts atomic write with lock → EPERM
  2. Falls back to non-atomic write → SUCCESS ✓
  3. BUG: Continues retrying atomic write infinitely (no backoff, no limit)
  4. Event loop blocked → stdin frozen

What Should Happen?

Expected Behavior

After fallback succeeds, CLI should:

  • Stop retrying atomic write
  • Return success
  • Not block event loop

Logs

[ERROR] Failed to save config with lock: EPERM [DEBUG] Falling back to non-atomic write [DEBUG] File written successfully with fallback [ERROR] Failed to save config with lock: EPERM ← REPEATS 20+ TIMES

Impact

  • Affects Windows corporate environments with restrictive GPOs
  • Only occurs in repos WITH SessionStart hooks
  • Repos without hooks work normally
  • Makes Claude Code CLI unusable in corporate settings

Suggested Fixes

  1. Stop retrying after successful fallback (critical)
  2. Add exponential backoff (max 3 retries)
  3. Add config option: "disableFileLocking": true
  4. Detect corporate environment and

Error Messages/Logs

## Logs
[ERROR] Failed to save config with lock: EPERM [DEBUG] Falling back to non-atomic write [DEBUG] File written successfully with fallback [ERROR] Failed to save config with lock: EPERM ← REPEATS 20+ TIMES

Steps to Reproduce

Reproduction

  1. Configure SessionStart hooks in .claude/settings.json
  2. Launch claude in project directory (Windows corporate environment)
  3. Hooks execute successfully (JSON output validates)
  4. CLI freezes - stdin becomes unresponsive

Claude Model

Sonnet (default)

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.31

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Happened every single time i tried session start hooks. Went through a thorough process of permission corrections and basically rebuilt (was running powershell as admin, a whole lotta fjckery with file property etc.
But now I really did pay attention. The hooks WORK in powershell normally. Other repos (with no session start hooks) also work.

View original on GitHub ↗

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