New session hangs indefinitely when cwd is HOME with no git repo - unscoped rg scan hits TCC-denied paths

Status Open
Reported on v2.1.263
Maintainer reply None cached
Activity 0 comments · opened Sep 8, 2026

Description

Starting a new interactive session with the current working directory set to the user's home directory ($HOME, not inside a git repository) hangs indefinitely — no response to any prompt, no error shown, no CPU usage. --safe-mode and --bare are unaffected (they start and respond normally); only a normal-mode session started from $HOME reproduces this. Passing an explicit empty --mcp-config '{"mcpServers":{}}' does not avoid the hang, ruling out MCP server connection as the cause.

Steps to reproduce

  1. cd ~ (home directory, not a git repo)
  2. claude --debug
  3. Send any prompt
  4. Session never responds. Process sits at ~0.1% CPU indefinitely.

Sessions started inside an actual project directory (a git repo) do not reproduce this.

Root cause (from --debug log)

The debug log shows a home-directory-wide rg (ripgrep) file-index scan running unscoped against the entire $HOME tree instead of being bounded to a project root (presumably because there is no git repo to establish a project boundary, so it falls back to $HOME). This walks into a wall of macOS TCC-protected directories the process has no permission to read:

rg error (signal=undefined, code=2, stderr: rg: /Users/<user>/.Trash: Operation not permitted (os error 1)
rg: /Users/<user>/Library/Caches/com.apple.ap.adprivacyd: Operation not permitted (os error 1)
rg: /Users/<user>/Library/Trial: Operation not permitted (os error 1)
rg: /Users/<user>/Library/Mail: Operation not permitted (os error 1)
rg: /Users/<user>/Pictures/Photos Library.photoslibrary: Operation not permitted (os error 1)
rg: /Users/<user>/Library/com.apple.aiml.instrumentation: Operation not permitted (os error 1)
rg: /Users/<user>/Library/Sharing: Operation not permitted (os error 1)
rg: /Users/<user>/Library/HomeKit: Operation not permitted (os error 1)
rg: /Users/<user>/Library/Messages: Operation not permitted (os error 1)
rg: /Users/<user>/Library/IdentityServices: Operation not permitted (os error 1)
rg: /Users/<user>/Library/Autosave Information: Operation not permitted (os error 1)
rg: /Users/<user>/Library/Daemon Containers: Operation not permitted (os error 1)
... (dozens more)

That is the last line the debug log ever writes. The rg subprocess itself exits (confirmed via ps — no rg process remains running), but nothing further is ever logged, and the parent claude process settles at ~0.1% CPU — genuinely idle/blocked, not busy-looping or crashed. Whatever consumes rg's error output for this specific shape (many code=2 / Operation not permitted lines) appears to hang rather than continuing or surfacing an error to the user.

Environment

  • Claude Code version: 2.1.263
  • macOS: 26.6.2 (Build 25G83)
  • Node.js: v26.5.0
  • Shell: zsh
  • Architecture: Darwin (Apple Silicon)

Expected behavior

Either:

  • The file-index scan should be bounded to the actual working directory rather than falling back to an unscoped $HOME walk, or
  • rg exiting with permission-denied errors on protected system paths (.Trash, Library/Mail, Photos Library.photoslibrary, Library/Messages, etc. — all completely standard, expected-to-be-inaccessible macOS paths) should be handled gracefully and the session should continue to respond to prompts, not hang indefinitely with no error surfaced.

Actual behavior

New session hangs indefinitely with zero CPU usage and no error message. The only way to recover is killing the process; a fresh cd into any git-repo project directory before launching avoids the bug entirely.

Workaround

cd into an actual project directory (any git repository) before running claude. A session launched from $HOME directly reliably reproduces the hang; one launched from inside a project does not.

View original on GitHub ↗