PaPoo
cover

exit code 128 が出るときの Claude Code の見分け方と、いま分かっている範囲

まず切り分けたいのは、同じ exit code 128 でも起き方が別物だという点です。今回の材料には、少なくとも 2 つのパターンがあります。ひとつは Claude Code on the web の remote execution sandbox で git clonegithub.com への HTTPS 通信を通せず、pip installgit+https://... 依存関係が落ちるケースです。もうひとつはデスクトップアプリで、リンクされた worktree で既にチェックアウト済みのブランチに対して git switch が主レポジトリ側で走り、Git が拒否して 128 で終わるケースです。前者は #71230、後者は #85543 です。

まず、あなたの症状がどちら寄りかを見ます。

remote execution sandbox で起きているなら、issue 側には「Outbound git clone over HTTPS to github.com fails inside the remote sandbox」「HTTPS proxy that the rest of the agent's tooling uses is not picked up by git」とあります。つまり、他の Claude Code のツールは動いていても、git clone だけが失敗する形です。再現例としては、pip install の途中で git clone --filter=blob:none --quiet https://github.com/... が走り、その時点で止まります。実際の issue では、GitHub MCP tools は正常でもこの経路だけ失敗すると報告されています #71230

デスクトップアプリ側なら、状況はかなり違います。issue #85543 では、リンクされた worktree のブランチにセッションを開始しようとすると、アプリが main repository checkout で git switch <branch> を実行してしまい、Git が「そのブランチは別 worktree ですでに使われている」として exit code 128 を返します。報告されているエラーメッセージはこうです。

Failed to switch to "codex/fable-organizer-profiles" in /Users/<user>/Developer/ai-os:
/usr/bin/git exited with code 128: fatal: 'codex/fable-organizer-profiles' is already
used by worktree at '/Users/<user>/Developer/ai-os/.worktrees/fable-organizer-pro

今回こちらで実際に確認できたのは、Claude Code の導入状態です。claude doctor は native 2.1.207 を使っていて、複数インストールが見つかると出ています。

$ claude doctor
Claude Code doctor

Running: native (2.1.207)
Commit: bc512d563325
Platform: darwin-arm64
Path: ~/.local/share/claude/versions/2.1.207
Config install method: native
Search: OK (bundled)
Auto-updates: enabled
Auto-update channel: latest
Last update attempt: none recorded

Multiple installations found
- npm-global at /usr/local/bin/claude
- native at ~/.local/bin/claude

Remote Control
Control this session from claude.ai/code or the Claude mobile app

1 warning found
- Leftover npm global installation at /usr/local/bin/claude
  Fix: Run: npm -g uninstall @anthropic-ai/claude-code

For a full setup checkup that can also fix issues, run /doctor in a Claude Code session.

実行ファイルの解決先も、複数あることが分かっています。

$ /usr/bin/which -a claude
~/.local/bin/claude
/usr/local/bin/claude
/usr/local/bin/claude

バージョンは次のとおりです。

$ claude --version
2.1.207 (Claude Code)

ただし、これらの出力だけでは、今回の exit code 128 が上のどちらの系統に当てはまるかは断定できません。少なくとも言えるのは、exit code 128 という数字だけでは足りず、失敗したコマンドが git clone なのか git switch なのか、あるいは別の Git 操作なのかを見る必要がある、ということです。

見分ける時の手がかりは単純です。pip install や GitHub の依存取得の途中で落ちるなら #71230 の系統が近いですし、特定ブランチでセッション開始するときに「already used by worktree」のような文言が出るなら #85543 の系統です。

現時点で確認できている範囲では、解決済みとして一般化できる手順はありません。#71230 は「other issue is not an exact dup」として閉じられ、#85543 は open のままです。なので、少なくともこの 2 件からは「exit code 128 は出るが、原因も対処も同じではない」と読むのが安全です。


検証環境

claude --version : 2.1.207 (Claude Code)
OS          : Darwin 25.3.0 (arm64)
Python      : 3.14.2
検証日時    : 2026-08-11T18:14:53+09:00

参照した Issue(anthropics/claude-code): #71230, #85543

同じ著者の記事