anthropics / anthropics/claude-code

[Bug] Interactive startup hangs indefinitely (blank screen) when TERM_PROGRAM=Apple_Terminal (v2.1.237, macOS)

オープン
#88,362 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area:tui bug has repro platform:macos
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

## Environment
- Claude Code v2.1.237, native installer binary (arm64 Mach-O at `~/.local/bin/claude`)
- macOS 26.5.2 (Darwin 25.5.0), Apple Silicon
- Shell: zsh; default terminal: macOS Terminal.app

## Summary
Launching `claude` interactively in Terminal.app hangs on a blank screen indefinitely before the first UI paint. The same launch is ready in ~0.5s in iTerm2/WezTerm or with `TERM_PROGRAM` unset. Confirmed in real Terminal.app: `TERM_PROGRAM= claude` starts instantly; plain `claude` hangs.

## Reproduction / evidence (PTY harness, real binary)
Launched `claude` under a Python `pty` harness (setsid, pty slave as stdio), varying only terminal identity:

| Condition | Result |
|---|---|
| `TERM_PROGRAM=Apple_Terminal` (full or minimal env) | emits 13 bytes then silent; **still hung after 240s, no recovery** |
| `TERM_PROGRAM` unset / `""` / `iTerm.app` / `WezTerm` | full UI painted in 0.50–0.69s |

The 13 bytes emitted before the hang: `\x1b7\x1b[r\x1b8\x1b[?25h` (save cursor, reset scroll region, restore cursor, show cursor). No terminal capability queries are sent before the hang, so it is not waiting on a terminal reply.

Not affected by: `--settings '{"tui":"default"}'`, `CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1`, plugin/MCP configuration (reproduces with `--strict-mcp-config`-equivalent trims), minimal environment (HOME/PATH/TERM/SHELL/USER only).

## Process state while hung
`sample ` shows the main thread parked in a bare blocking file open, 100% of samples, CPU time frozen (no growth between t=2s and t=10s):

```
1658 ??? (in 2.1.237) load address ... + 0x196afa8
1658 openat$NOCANCEL (in libsystem_kernel.dylib) + 76
1658 __openat_nocancel (in libsystem_kernel.dylib) + 8
```

Other observations while hung:
- One zombie child is left unreaped; PATH-shim tracing shows startup shells out to `/usr/bin/security find-generic-password -a -w -s "Claude Code-credentials"` (×3) — these complete instantly and are not the block.
- MCP stdio children (spawned before the hang) are alive and idle.
- `lsof` shows nothing unusual; the blocking `openat` target could not be identified without root (lldb attach denied by hardened runtime; no `fs_usage` without sudo).
- `-p`/non-interactive mode is unaffected (full run ~6s including API call).

## Workaround
`TERM_PROGRAM= claude` (or any non-Apple_Terminal value). Guarded alias:

```zsh
[[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && alias claude='TERM_PROGRAM= claude'
```

## Expected
Interactive startup in Terminal.app paints the UI in well under a second, as it does in every other terminal identity.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start by reproducing the launch with the provided Python PTY harness while varying only TERM_PROGRAM, then compare the process state and emitted bytes. Trace the interactive startup path around the blocking openat and the Apple_Terminal condition; done means Terminal.app paints the UI promptly without the indefinite hang, while other terminal identities remain unaffected.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
macos, python, zsh
領域
cli, operating-systems
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。