| domain | archive |
|---|---|
| title | Native Claude Code Wsl Bare Fix |
| verification | metadata-normalized |
| source | skill-pipeline |
| status | draft |
| created | 2026-05-09 |
(此 lesson 从 skill native-claude-code-wsl-bare-fix 自动提取,待补全)
(待补充)
Native Claude Code (v2.1.117) interactive mode in WSL fails with a 402 payment error. The issue is NOT account balance — it's that interactive mode calls https://api.anthropic.com/api/claude_cli/bootstrap for session initialization, which bypasses ANTHROPIC_BASE_URL proxy and goes directly to Anthropic's API. API keys that work through a proxy fail this direct bootstrap call (401/402).
Pipe mode (claude -p) works fine because it doesn't call bootstrap.
The --bare flag (CLAUDE_CODE_SIMPLE=1) skips bootstrap entirely. Create a wrapper script:
-
Rename the real binary:
mv ~/.local/bin/claude ~/.local/bin/claude.real
-
Create wrapper at
~/.local/bin/claude:#!/bin/bash exec ~/.local/bin/claude.real --bare "$@" chmod +x ~/.local/bin/claude
This makes claude (interactive) work through proxy without bootstrap.
- Debug log:
claude --debug-file /tmp/claude-debug.log— look for[Bootstrap] Fetch failed: 401 - Bootstrap endpoint:
POST https://api.anthropic.com/api/claude_cli/bootstrap(hardcoded, cannot be proxied) - Proxy test:
curl -X POST "http://proxy-host/v1/messages"with API key
推荐方案已变更:优先使用 native-claude-code-wsl-proxy-fix skill 中的"方案二"——直接配置 ~/.claude/settings.json 使用 MiniMax API,不走 proxy,最简单最稳。
--bare wrapper 方案(本文)作为备用保留,适用于 proxy 是唯一可用 API 的场景。
claude -pworks butclaude(interactive) shows 402- Debug log shows
[Bootstrap] Fetch failed: 401 claude doctorhangs indefinitely- API key works fine when tested directly against proxy
- cc-haha (NanmiCoder/cc-haha) is a separate fork with its own proxy architecture — not relevant to this fix
customApiKeyResponses.rejectedin~/.claude.jsonmay accumulate key fragments from failed attempts — clear it if settings UI shows stale keys
(待补充)