claude --worktree hangs indefinitely on Linux (stuck on API call before init)
Description
claude --worktree hangs indefinitely with a completely blank terminal on Linux. Regular claude in the same directory starts within seconds.
Environment
- Claude Code version: 2.1.71
- OS: Ubuntu Linux (kernel 6.17.0-14-generic)
- Shell: zsh
- Platform: x86_64
Steps to Reproduce
cdinto any git repository- Run
claude --worktree - Terminal stays completely blank -- no TUI renders, no spinner, no output
- Process must be killed manually
Regular claude (without --worktree) in the same directory starts fine.
Diagnostic Findings
Process state while hanging
Inspected the hanging process via /proc and ss:
- State:
S (sleeping), all threads sleeping - wchan:
ep_poll(blocked in Node.js event loop waiting for I/O) - No child processes: MCP servers, hooks, worktree session -- none spawned yet. Hang is very early in initialization.
- Only ~17 file descriptors: far fewer than a fully initialized session
- Single network socket:
ESTAB 0 0 <local>:46118 <anthropic-api>:443 - TCP connection to
api.anthropic.com:443is ESTABLISHED - Send queue = 0, receive queue = 0 (no data flowing in either direction)
- Process is waiting for an HTTP response that never arrives
What was ruled out
All local factors were systematically tested and eliminated:
| Hypothesis | Result |
|---|---|
| Git hooks slow | post-checkout hook completes in 0.02s |
| Git worktree creation slow | git worktree add completes in 0.06s |
| MCP stdio servers hanging | Not spawned yet -- hang is before MCP init |
| MCP HTTP servers unreachable | All local MCP servers respond normally |
| SessionStart hooks hanging | All hooks have 5s timeouts, server is running |
| Process stopped by SIGTTOU | Only happens under timeout wrapper; direct run shows S (sleeping) with correct foreground process group (TPGID = PGID) |
strace confirmation
Running under strace -f shows the process:
- Loads shared libraries (libc, libpthread, etc.)
- Initializes V8 runtime, creates worker threads (clone3)
- Opens project directory
- Stops -- all threads enter futex waits, no further syscalls
No fork/exec/clone for child processes (git, MCP servers, etc.) ever occurs.
Expected Behavior
claude --worktree should create a git worktree and start an interactive session in it, similar to how regular claude starts.
Actual Behavior
Process hangs indefinitely with a blank terminal, stuck waiting for an HTTPS response from api.anthropic.com that never arrives. The hang occurs before any local initialization (worktree creation, MCP servers, hooks, TUI rendering).
Workaround
Manually create the worktree and run claude in it:
git worktree add /tmp/my-feature -b feature/my-work
cd /tmp/my-feature
claudeThis issue has 4 comments on GitHub. Read the full discussion on GitHub ↗