8 8
9本页列出 Claude Code 显示的运行时错误以及如何从每个错误中恢复,以及当响应似乎有问题但没有错误时要检查的内容。对于安装错误(如 `command not found` 或设置期间的 TLS 失败),请参阅[排查安装和登录问题](/docs/zh-CN/troubleshoot-install)。9本页列出 Claude Code 显示的运行时错误以及如何从每个错误中恢复,以及当响应似乎有问题但没有错误时要检查的内容。对于安装错误(如 `command not found` 或设置期间的 TLS 失败),请参阅[排查安装和登录问题](/docs/zh-CN/troubleshoot-install)。
10 10
11除了[包装器和 IDE 错误](#wrapper-and-ide-errors)(由启动程序打印而不是 Claude Code 本身打印)外,这些错误和恢复命令适用于 CLI、[桌面应用](/docs/zh-CN/desktop)和[云会话](/docs/zh-CN/claude-code-on-the-web),因为这三个都包装相同的 Claude Code CLI。对于其他表面特定的问题,请参阅该表面页面上的故障排除部分。11除了[包装器和 IDE 错误](#wrapper-and-ide-errors)(由启动程序打印而不是 Claude Code 本身打印)外,这些错误和恢复命令适用于 CLI、[桌面应用](/docs/zh-CN/desktop)和[云端会话](/docs/zh-CN/claude-code-on-the-web),因为这三个都包装相同的 Claude Code CLI。对于其他特定于使用入口的问题,请参阅该使用入口页面上的故障排除部分。
12 12
13<Note>13<Note>
14 Claude Code 调用 Claude API 来获取模型响应,因此大多数运行时错误映射到底层 API 错误代码。本页介绍每个错误在 Claude Code 中的含义以及如何恢复。有关原始 HTTP 状态代码定义,请参阅 [Claude Platform 错误参考](https://platform.claude.com/docs/en/api/errors)。14 Claude Code 调用 Claude API 来获取模型响应,因此大多数运行时错误映射到底层 API 错误代码。本页介绍每个错误在 Claude Code 中的含义以及如何恢复。有关原始 HTTP 状态代码定义,请参阅 [Claude Platform 错误参考](https://platform.claude.com/docs/en/api/errors)。
75| `Remote Control stopped — the app running this session is now signed in to a different Claude account` | [身份验证](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |75| `Remote Control stopped — the app running this session is now signed in to a different Claude account` | [身份验证](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |
76| `Remote Control stopped — the app running this session is signed out of Claude` | [身份验证](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |76| `Remote Control stopped — the app running this session is signed out of Claude` | [身份验证](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |
77| `Couldn't verify your organization's policy for remote control` | [Troubleshoot Remote Control](/docs/zh-CN/remote-control#couldnt-verify-your-organizations-policy-for-remote-control) |77| `Couldn't verify your organization's policy for remote control` | [Troubleshoot Remote Control](/docs/zh-CN/remote-control#couldnt-verify-your-organizations-policy-for-remote-control) |
78| `Remote Control is disabled by your organization's policy` | [Troubleshoot Remote Control](/docs/zh-CN/remote-control#remote-control-is-disabled-by-your-organizations-policy) |
79| `Remote Control was turned off by your organization's policy` | [Troubleshoot Remote Control](/docs/zh-CN/remote-control#remote-control-was-turned-off-by-your-organizations-policy) |
78| `OAuth token revoked` / `OAuth token has expired` | [身份验证](#oauth-token-revoked-or-expired) |80| `OAuth token revoked` / `OAuth token has expired` | [身份验证](#oauth-token-revoked-or-expired) |
81| `Failed to authenticate: OAuth token revoked` | [身份验证](#oauth-token-revoked-or-expired) |
82| `Your account does not have access to Claude. Please login again or contact your administrator.` | [身份验证](#oauth-token-revoked-or-expired) |
79| `API Error: 401 Invalid authentication credentials` | [身份验证](#api-error-401-invalid-authentication-credentials) |83| `API Error: 401 Invalid authentication credentials` | [身份验证](#api-error-401-invalid-authentication-credentials) |
80| `Login expired · Please run /login` | [身份验证](#login-expired) |84| `Login expired · Please run /login` | [身份验证](#login-expired) |
81| `Failed to start OAuth callback server` | [身份验证](#failed-to-start-oauth-callback-server) |85| `Failed to start OAuth callback server` | [身份验证](#failed-to-start-oauth-callback-server) |
186| `The connection dropped while downloading the update` | [安装错误](#the-connection-dropped-while-downloading-the-update) |190| `The connection dropped while downloading the update` | [安装错误](#the-connection-dropped-while-downloading-the-update) |
187| `Download timed out: exceeded the total deadline` | [安装错误](#the-connection-dropped-while-downloading-the-update) |191| `Download timed out: exceeded the total deadline` | [安装错误](#the-connection-dropped-while-downloading-the-update) |
188| `--bg and --print conflict` | [命令行错误](#conflict-between-bg-and-print) |192| `--bg and --print conflict` | [命令行错误](#conflict-between-bg-and-print) |
193| `Error: Cannot use both --append-subagent-system-prompt and --append-subagent-system-prompt-file. Please use only one.` | [命令行错误](#conflict-between-a-system-prompt-flag-and-its-file-form) |
189| `Cloud sessions cannot be created from a --restricted session` | [命令行错误](#cloud-sessions-cannot-be-created-from-a-restricted-session) |194| `Cloud sessions cannot be created from a --restricted session` | [命令行错误](#cloud-sessions-cannot-be-created-from-a-restricted-session) |
190| `Cloud sessions are disabled by your organization's policy` | [命令行错误](#cloud-sessions-are-disabled-by-your-organizations-policy) |195| `Cloud sessions are disabled by your organization's policy` | [命令行错误](#cloud-sessions-are-disabled-by-your-organizations-policy) |
191| `Couldn't verify your organization's policy for cloud sessions` | [命令行错误](#cloud-sessions-are-disabled-by-your-organizations-policy) |196| `Couldn't verify your organization's policy for cloud sessions` | [命令行错误](#cloud-sessions-are-disabled-by-your-organizations-policy) |
203| `Could not read Claude Code config` | [命令行错误](#could-not-read-claude-code-config) |208| `Could not read Claude Code config` | [命令行错误](#could-not-read-claude-code-config) |
204| `Could not import <server>: <reason>` | [命令行错误](#could-not-import-a-server-from-claude-desktop) |209| `Could not import <server>: <reason>` | [命令行错误](#could-not-import-a-server-from-claude-desktop) |
205| `Cannot add MCP server to scope: managed` | [命令行错误](#cannot-add-mcp-server-to-the-managed-scope) |210| `Cannot add MCP server to scope: managed` | [命令行错误](#cannot-add-mcp-server-to-the-managed-scope) |
211| `Cannot add MCP server: your organization's managed settings allow only MCP servers that plugins provide` | [命令行错误](#cannot-add-mcp-server-when-managed-settings-allow-only-plugin-servers) |
206| `is Anthropic-hosted and doesn't support local OAuth` | [命令行错误](#anthropic-hosted-and-doesnt-support-local-oauth) |212| `is Anthropic-hosted and doesn't support local OAuth` | [命令行错误](#anthropic-hosted-and-doesnt-support-local-oauth) |
207| `Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes` | [命令行错误](#cant-read-mcp-json) |213| `Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes` | [命令行错误](#cant-read-mcp-json) |
208| `MCP server "<name>" was not saved to` / `was not removed from` | [命令行错误](#mcp-server-was-not-saved-or-removed) |214| `MCP server "<name>" was not saved to` / `was not removed from` | [命令行错误](#mcp-server-was-not-saved-or-removed) |
246| `Marketplace name impersonates an official Anthropic/Claude marketplace` | [Plugin 错误](#claude-code-refuses-the-marketplace-name) |252| `Marketplace name impersonates an official Anthropic/Claude marketplace` | [Plugin 错误](#claude-code-refuses-the-marketplace-name) |
247| `Marketplace "<name>" is already added from a different source` | [Plugin 错误](#marketplace-is-already-added-from-a-different-source) |253| `Marketplace "<name>" is already added from a different source` | [Plugin 错误](#marketplace-is-already-added-from-a-different-source) |
248| `"<name>" is another spelling of "<reserved>", a reserved marketplace name` | [Plugin 错误](#marketplace-name-is-another-spelling-of-a-reserved-name) |254| `"<name>" is another spelling of "<reserved>", a reserved marketplace name` | [Plugin 错误](#marketplace-name-is-another-spelling-of-a-reserved-name) |
255| `Marketplace "<name>" is added but ignored` | [Plugin 故障排除](/docs/zh-CN/plugins/troubleshooting#marketplace-is-added-but-ignored) |
256| `Marketplace "<name>" is registered but was refused (see the debug log)` | [Plugin 故障排除](/docs/zh-CN/plugins/troubleshooting#marketplace-is-added-but-ignored) |
249| `references ${user_config.*} in a shell-form command` | [Plugin 错误](#plugin-command-references-user-config) |257| `references ${user_config.*} in a shell-form command` | [Plugin 错误](#plugin-command-references-user-config) |
250| `Monitor "<name>" from plugin <plugin> references ${user_config.*} in its command` | [Plugin 错误](#plugin-command-references-user-config) |258| `Monitor "<name>" from plugin <plugin> references ${user_config.*} in its command` | [Plugin 错误](#plugin-command-references-user-config) |
251| `headersHelper for MCP server '<name>' references ${user_config.*}` | [Plugin 错误](#plugin-command-references-user-config) |259| `headersHelper for MCP server '<name>' references ${user_config.*}` | [Plugin 错误](#plugin-command-references-user-config) |
252| `Plugin archive integrity check failed` | [Plugin 错误](#plugin-archive-integrity-check-failed) |260| `Plugin archive integrity check failed` | [Plugin 错误](#plugin-archive-integrity-check-failed) |
261| `An npm plugin source must name a registry package` | [Plugin 故障排除](/docs/zh-CN/plugins/troubleshooting#an-npm-plugin-source-must-name-a-registry-package) |
253| `path escapes plugin directory` | [Plugin 错误](#path-escapes-plugin-directory) |262| `path escapes plugin directory` | [Plugin 错误](#path-escapes-plugin-directory) |
254| `path could not be checked` | [Plugin 错误](#path-could-not-be-checked) |263| `path could not be checked` | [Plugin 错误](#path-could-not-be-checked) |
255| `its marketplace entry path does not stay inside the marketplace directory` | [Plugin 错误](#marketplace-entry-path-does-not-stay-inside-the-marketplace-directory) |264| `its marketplace entry path does not stay inside the marketplace directory` | [Plugin 错误](#marketplace-entry-path-does-not-stay-inside-the-marketplace-directory) |
360Claude Code 重试这些故障:369Claude Code 重试这些故障:
361 370
362* 在 Claude 响应开始流式传输之前到达的服务器错误、过载响应和请求超时。371* 在 Claude 响应开始流式传输之前到达的服务器错误、过载响应和请求超时。
363* 连接断开。当连接在请求过程中途断开,且 Claude 尚未完成其响应的任何部分(包括其思考过程)时,Claude Code 会使用相同的退避重新发送请求,转换继续进行,即使某些文本已经开始流式传输。当连接在 Claude 完成思考之后但在开始任何文本或工具调用之前断开时,Claude Code 改为快速连续重新发送请求最多两次,如果连接在该点继续断开,则以 `Connection lost before a response was produced` 结束转换。372* 在 Claude 完成思考之后、但在开始任何文本或工具调用之前到达的服务器错误或过载响应。Claude Code 会在该点重试服务器错误最多两次。在 v2.1.284 之前,Claude Code 会在该点以该错误结束轮次。
364* Claude Code 检测到的连接在您的计算机进入睡眠状态时在请求过程中途被破坏。Claude Code 将其计为上述规则下的断开连接;一旦重试标签命名了具体原因,它会读作 `Connection lost while your computer was asleep`,如果转换在 Claude 完成思考之后但在任何文本或工具调用之前结束,消息会读作 `Your computer went to sleep before a response was produced`。373* 连接断开。当连接在请求过程中途断开,且 Claude 尚未完成其响应的任何部分(包括其思考过程)时,Claude Code 会使用相同的退避重新发送请求,轮次继续进行,即使某些文本已经开始流式传输。当连接在 Claude 完成思考之后但在开始任何文本或工具调用之前断开时,Claude Code 改为快速连续重新发送请求最多两次,如果连接在该点继续断开,则以 `Connection lost before a response was produced` 结束轮次。
365* 停滞的响应流,当响应头已到达但 Claude 响应的任何部分都未到达,或当 Claude 完成思考但尚未开始任何文本或工具调用时:Claude Code 中止停滞连接并最多重新发送一次请求,不在上述 10 次尝试预算之外。如果响应在 Claude 完成思考之后但在任何文本或工具调用之前第二次停滞,Claude Code 以 `The response stalled before a response was produced` 结束转换。374* Claude Code 检测到的连接在您的计算机进入睡眠状态时在请求过程中途被破坏。Claude Code 将其计为上述规则下的断开连接;一旦重试标签命名了具体原因,它会读作 `Connection lost while your computer was asleep`,如果轮次在 Claude 完成思考之后但在任何文本或工具调用之前结束,消息会读作 `Your computer went to sleep before a response was produced`。
366* 流式请求 API 从未用响应头回答,在 [first-byte deadline runs](/docs/zh-CN/network-config#streaming-idle-watchdogs) 的连接上:Claude Code 在截止时间中止它,并在重试预算内每个模型请求最多重新发送一次,然后如果该尝试也未得到回答,则以 [No response from API](#no-response-from-api) 结束转换。在其他连接上,请求等待 `API_TIMEOUT_MS`。当您设置 `CLAUDE_CODE_RETRY_WATCHDOG` 时,一次重试上限不适用。375* 停滞的响应流,当响应头已到达但 Claude 响应的任何部分都未到达,或当 Claude 完成思考但尚未开始任何文本或工具调用时:Claude Code 中止停滞连接并最多重新发送一次请求,不计入上述 10 次尝试预算。如果响应在 Claude 完成思考之后但在任何文本或工具调用之前第二次停滞,Claude Code 以 `The response stalled before a response was produced` 结束轮次。
376* 流式请求 API 从未用响应头回答,在 [first-byte deadline runs](/docs/zh-CN/network-config#streaming-idle-watchdogs) 的连接上:Claude Code 在截止时间中止它,并在重试预算内每个模型请求最多重新发送一次,然后如果该尝试也未得到回答,则以 [No response from API](#no-response-from-api) 结束轮次。在其他连接上,请求等待 `API_TIMEOUT_MS`。当您设置 `CLAUDE_CODE_RETRY_WATCHDOG` 时,一次重试上限不适用。
367* 临时 429 节流,但不是网关的支出限制 `429`,这不是节流;请参阅 [Spend limit reached](#spend-limit-reached)。377* 临时 429 节流,但不是网关的支出限制 `429`,这不是节流;请参阅 [Spend limit reached](#spend-limit-reached)。
368 * 当您使用 claude.ai 订阅登录时,这包括不携带您计划配额头的 429 节流。在 v2.1.199 之前,Claude Code 仅对 API 密钥和企业登录重试这些节流。378 * 当您使用 claude.ai 订阅登录时,这包括不携带您套餐配额头的 429 节流。在 v2.1.199 之前,Claude Code 仅对 API 密钥和企业登录重试这些节流。
369* 因为输入加上 `max_tokens` 超过上下文限制而被拒绝的请求。以相同方式重新发送它会以相同方式失败,所以 Claude Code 使用减少的 `max_tokens` 重试,并在两种情况下停止重试并改为压缩:379* 因为输入加上 `max_tokens` 超过上下文限制而被拒绝的请求。以相同方式重新发送它会以相同方式失败,所以 Claude Code 使用减少的 `max_tokens` 重试,并在两种情况下停止重试并改为压缩:
370 * 当没有减少可以适应时,例如当对话本身几乎填满上下文窗口时。380 * 当没有减少可以适应时,例如当对话本身几乎填满上下文窗口时。
371 * 当重试无法进一步缩小 `max_tokens` 时。在 v2.1.218 之前,Claude Code 可以重新发送仍然不适应的减少请求,例如当扩展思考预算超过剩余上下文时,直到重试预算用尽。381 * 当重试无法进一步缩小 `max_tokens` 时。在 v2.1.218 之前,Claude Code 可以重新发送仍然不适应的减少请求,例如当扩展思考预算超过剩余上下文时,直到重试预算用尽。
372* [Google Cloud 的 Agent Platform](/docs/zh-CN/google-vertex-ai) 上过期或缺失的 Google Cloud 凭证,或在您的机器上加载失败的 AWS 凭证。Claude Code 丢弃其缓存的凭证并重试最多两次,然后报告错误以便您可以立即重新身份验证,如 [Could not load AWS or Google Cloud credentials](#could-not-load-aws-or-google-cloud-credentials) 下所述。在 v2.1.228 之前,Claude Code 通过完整重试预算重试失败的 Google Cloud 凭证,然后显示错误。382* [Google Cloud 的 Agent Platform](/docs/zh-CN/google-vertex-ai) 上过期或缺失的 Google Cloud 凭据,或在您的机器上加载失败的 AWS 凭据。Claude Code 丢弃其缓存的凭据并重试最多两次,然后报告错误以便您可以立即重新身份验证,如 [Could not load AWS or Google Cloud credentials](#could-not-load-aws-or-google-cloud-credentials) 下所述。在 v2.1.228 之前,Claude Code 通过完整重试预算重试失败的 Google Cloud 凭据,然后显示错误。
373* 来自 Anthropic API 的 `401` 或 `403`,直接或通过 [LLM gateway](/docs/zh-CN/llm-gateway),而 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本提供凭证。Claude Code 重新运行脚本并使用其新输出重试,在完整重试预算内。当脚本本身在重新运行时失败时,Claude Code 改为显示 [Your apiKeyHelper script is failing](#your-apikeyhelper-script-is-failing)。383* 来自 Anthropic API 的 `401` 或 `403`,直接或通过 [LLM gateway](/docs/zh-CN/llm-gateway),而 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本提供凭据。Claude Code 重新运行脚本并使用其新输出重试,在完整重试预算内。当脚本本身在重新运行时失败时,Claude Code 改为显示 [Your apiKeyHelper script is failing](#your-apikeyhelper-script-is-failing)。
374 384
375在 v2.1.227 之前,`Connection lost before a response was produced` 读作 `Connection closed while thinking, before producing a response`,`The response stalled before a response was produced` 读作 `Response stalled while thinking, before producing a response`。385在 v2.1.227 之前,`Connection lost before a response was produced` 读作 `Connection closed while thinking, before producing a response`,`The response stalled before a response was produced` 读作 `Response stalled while thinking, before producing a response`。
376 386
377Claude Code 不重试这些故障:387Claude Code 不重试这些故障:
378 388
379* TLS 证书验证失败,例如 TLS 检查代理、缺失的 `NODE_EXTRA_CA_CERTS` 包或过期的证书。Claude Code 在第一次尝试时报告错误,以便您可以立即修复证书设置;请参阅 [SSL certificate errors](#ssl-certificate-errors)。Claude Code 仍然重试瞬时 TLS 条件,例如握手超时。在 v2.1.199 之前,Claude Code 通过完整重试预算重试证书失败,然后显示错误。389* TLS 证书验证失败,例如 TLS 检查代理、缺失的 `NODE_EXTRA_CA_CERTS` 包或过期的证书。Claude Code 在第一次尝试时报告错误,以便您可以立即修复证书设置;请参阅 [SSL certificate errors](#ssl-certificate-errors)。Claude Code 仍然重试瞬时 TLS 条件,例如握手超时。在 v2.1.199 之前,Claude Code 通过完整重试预算重试证书失败,然后显示错误。
380* 服务器错误、断开连接或停滞流在 Claude 完成文本块或工具调用之后到达,或在完成思考之后开始一个但在完成响应之前。Claude Code 不重新运行请求,因为这可能会执行相同的工具调用两次。它保留 Claude 完成的内容,运行 Claude 完成的任何工具调用,并从其结果继续转换。对于您在交互式会话和非交互式会话中看到的内容,请阅读 [The response above may be incomplete](#the-response-above-may-be-incomplete)。在 v2.1.199 之前,当服务器错误在流中途到达时,Claude Code 丢弃部分输出并将整个转换报告为错误。390* 服务器错误、断开连接或停滞流在 Claude 完成文本块或工具调用之后到达,或在完成思考之后开始一个但在完成响应之前。Claude Code 不重新运行请求,因为这可能会执行相同的工具调用两次。它保留 Claude 完成的内容,运行 Claude 完成的任何工具调用,并从其结果继续轮次。对于您在交互式会话和非交互式会话中看到的内容,请阅读 [The response above may be incomplete](#the-response-above-may-be-incomplete)。在 v2.1.199 之前,当服务器错误在流中途到达时,Claude Code 丢弃部分输出并将整个轮次报告为错误。
381* 在 Claude 完成响应之后到达的故障:无需重试任何内容,所以 Claude Code 保留完整响应并正常结束转换。391* 在 Claude 完成响应之后到达的故障:无需重试任何内容,所以 Claude Code 保留完整响应并正常结束轮次。
382* [Amazon Bedrock 流式响应具有意外的 content-type](#bedrock-streaming-response-has-an-unexpected-content-type),因为重写响应的网关或代理会以相同方式重写重试。需要 Claude Code v2.1.208 或更高版本。392* [Amazon Bedrock 流式响应具有意外的 content-type](#bedrock-streaming-response-has-an-unexpected-content-type),因为重写响应的网关或代理会以相同方式重写重试。需要 Claude Code v2.1.208 或更高版本。
383* 失败的流式请求的非流式重试获得成功状态但 [body 中没有 Claude API 消息](#api-returned-an-empty-or-malformed-response)。Claude Code 以该错误结束转换。393* 失败的流式请求的非流式重试获得成功状态但 [body 中没有 Claude API 消息](#api-returned-an-empty-or-malformed-response)。Claude Code 以该错误结束轮次。
384* 您的组织的策略检查拒绝的请求,其表现为携带拒绝消息的 `API Error:` 行。您的组织管理员使用 [Inference hooks](https://platform.claude.com/docs/en/manage-claude/inference-hooks)(Claude Enterprise 功能)设置检查,消息以他们配置的说明结尾,或默认告诉您联系他们。Claude Code 不会将拒绝的请求重新发送到相同模型或 [fallback model](/docs/zh-CN/model-config#fallback-model-chains),因为拒绝涉及请求的内容而不是模型。在 v2.1.239 之前,Claude Code 可以重新发送拒绝的请求,不流式传输或在配置的备用模型上,然后向您显示拒绝。394* 您的组织的策略检查拒绝的请求,其表现为携带拒绝消息的 `API Error:` 行。您的组织管理员使用 [Inference hooks](https://platform.claude.com/docs/en/manage-claude/inference-hooks)(Claude Enterprise 功能)设置检查,消息以他们配置的说明结尾,或默认告诉您联系他们。Claude Code 不会将拒绝的请求重新发送到相同模型或 [fallback model](/docs/zh-CN/model-config#fallback-model-chains),因为拒绝涉及请求的内容而不是模型。在 v2.1.239 之前,Claude Code 可以重新发送拒绝的请求,不流式传输或在配置的备用模型上,然后向您显示拒绝。
385 395
386<h3 id="what-you-see-while-claude-code-retries-or-waits">396<h3 id="what-you-see-while-claude-code-retries-or-waits">
393 403
394如果在请求仍然待处理时响应流上 20 秒内没有数据到达,微调器显示 `Waiting for API response · will retry in … · check your network`,然后任何重试都尚未开始。请求尚未失败:倒计时运行到 Claude Code 中止停滞连接的点。中止后,您看到的内容取决于响应已进行的距离:404如果在请求仍然待处理时响应流上 20 秒内没有数据到达,微调器显示 `Waiting for API response · will retry in … · check your network`,然后任何重试都尚未开始。请求尚未失败:倒计时运行到 Claude Code 中止停滞连接的点。中止后,您看到的内容取决于响应已进行的距离:
395 405
396* 在 Claude 完成文本块或工具调用之前,或在完成思考之后开始一个,Claude Code 重试请求或以错误结束转换。[Automatic retries](#automatic-retries) 说明它重试哪些停滞以及多少次。406* 在 Claude 完成文本块或工具调用之前,或在完成思考之后开始一个,Claude Code 重试请求或以错误结束轮次。[Automatic retries](#automatic-retries) 说明它重试哪些停滞以及多少次。
397* 在 Claude 完成文本块或工具调用之后,或在完成思考之后开始一个,但在 Claude 完成响应之前,Claude Code 保留 Claude 完成的内容,从 Claude 完成的任何工具调用继续转换,并显示 [The response above may be incomplete](#the-response-above-may-be-incomplete)。在非交互式会话中,以及对于任何会话中的子代理响应,Claude Code 可能首先提示 Claude 继续响应;该条目说明何时执行以及何时您仍然在那里看到通知。407* 在 Claude 完成文本块或工具调用之后,或在完成思考之后开始一个,但在 Claude 完成响应之前,Claude Code 保留 Claude 完成的内容,从 Claude 完成的任何工具调用继续轮次,并显示 [The response above may be incomplete](#the-response-above-may-be-incomplete)。在非交互式会话中,以及对于任何会话中的子代理响应,Claude Code 可能首先提示 Claude 继续响应;该条目说明何时执行以及何时您仍然在那里看到通知。
398* 在 Claude 完成响应之后,Claude Code 正常结束转换。408* 在 Claude 完成响应之后,Claude Code 正常结束轮次。
399 409
400一旦数据恢复或重试成功,横幅会自动清除。如果它在每次尝试时重新出现,将其视为 [network issue](#unable-to-connect-to-api)。在 v2.1.185 之前,横幅在 10 秒后出现,措辞不同。410一旦数据恢复或重试成功,横幅会自动清除。如果它在每次尝试时重新出现,将其视为 [network issue](#unable-to-connect-to-api)。在 v2.1.185 之前,横幅在 10 秒后出现,措辞不同。
401 411
402当 Claude 咨询 [advisor](/docs/zh-CN/advisor) 时,横幅在 90 秒无数据后出现,而不是 20 秒,因为长时间的顾问审查可以发送超过 20 秒的任何内容。在 v2.1.214 之前,20 秒阈值也适用于顾问调用,所以横幅在顾问审查期间出现,即使没有任何问题。412当 Claude 咨询 [advisor](/docs/zh-CN/advisor) 时,横幅在 90 秒无数据后出现,而不是 20 秒,因为长时间的顾问审查可能在远超 20 秒的时间内不发送任何数据。在 v2.1.214 之前,20 秒阈值也适用于顾问调用,所以横幅在顾问审查期间出现,即使没有任何问题。
403 413
404<h3 id="tune-retry-behavior">414<h3 id="tune-retry-behavior">
405 调整重试行为415 调整重试行为
418 服务器错误428 服务器错误
419</h2>429</h2>
420 430
421这些错误中的大多数来自推理提供商:Anthropic API 上的 Anthropic 服务,以及 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或自定义网关上该提供商端点后面的服务。[Auto mode 无法确定操作的安全性](#auto-mode-cannot-determine-the-safety-of-an-action)和[Agent 因 API 错误而提前终止](#agent-terminated-early-due-to-an-api-error)也涵盖了您这一方的原因,例如无法调用分类器模型的 Amazon Bedrock 账户或达到使用限制的子代理。431这些错误中的大多数来自推理提供商:Anthropic API 上的 Anthropic 服务,以及 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或自定义网关上该提供商端点后面的服务。[自动模式无法确定操作的安全性](#auto-mode-cannot-determine-the-safety-of-an-action)和[Agent 因 API 错误而提前终止](#agent-terminated-early-due-to-an-api-error)也涵盖了您这一方的原因,例如无法调用分类器模型的 Amazon Bedrock 账户或达到用量限制的子代理。
422 432
423<h3 id="api-error-500-internal-server-error">433<h3 id="api-error-500-internal-server-error">
424 API Error: 500 Internal server error434 API Error: 500 Internal server error
432 442
433尾部句子指出了检查服务健康状况的位置,因提供商而异。Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 配置会指出该提供商的服务状态。自定义 `ANTHROPIC_BASE_URL` 会指出网关主机。443尾部句子指出了检查服务健康状况的位置,因提供商而异。Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 配置会指出该提供商的服务状态。自定义 `ANTHROPIC_BASE_URL` 会指出网关主机。
434 444
435API 本身的 5xx 表示 API 内部出现了意外故障。它不是由您的提示、设置或账户引起的。445API 本身的 5xx 表示 API 内部出现了意外故障。它不是由您的提示词、设置或账户引起的。
436 446
437当代理、负载均衡器或网关用 HTML 错误页面回复时,消息显示状态代码和页面的标题,例如 `API Error: 502 Bad Gateway`。对于没有标题的页面,消息显示状态代码及其标准名称。在 v2.1.281 之前,当页面有标题时状态代码被丢弃,当页面没有标题时打印页面的原始标记。447当代理、负载均衡器或网关用 HTML 错误页面回复时,消息显示状态代码和页面的标题,例如 `API Error: 502 Bad Gateway`。对于没有标题的页面,消息显示状态代码及其标准名称。在 v2.1.281 之前,当页面有标题时状态代码被丢弃,当页面没有标题时打印页面的原始标记。
438 448
439**应该做什么:**449**应该做什么:**
440 450
441* 检查 [status.claude.com](https://status.claude.com) 或消息中指出的提供商状态页面,查看是否有活跃事件451* 检查 [status.claude.com](https://status.claude.com) 或消息中指出的提供商状态页面,查看是否有活跃事件
442* 等待一分钟,然后再次发送您的消息。您的原始消息仍在对话中,因此对于较长的提示,您可以输入 `try again` 而不是粘贴整个内容。452* 等待一分钟,然后再次发送您的消息。您的原始消息仍在对话中,因此对于较长的提示词,您可以输入 `try again` 而不是粘贴整个内容。
443* 如果错误持续存在且没有发布事件,请运行 `/feedback` 以便 Anthropic 可以使用您的请求详情进行调查。如果您的环境中 `/feedback` 不可用,请参阅[报告错误](#report-an-error)。453* 如果错误持续存在且没有发布事件,请运行 `/feedback` 以便 Anthropic 可以使用您的请求详情进行调查。如果您的环境中 `/feedback` 不可用,请参阅[报告错误](#report-an-error)。
444 454
445<h3 id="api-error-repeated-529-overloaded-errors">455<h3 id="api-error-repeated-529-overloaded-errors">
454 464
455尾部句子因提供商而异,方式与上面的 500 错误相同。465尾部句子因提供商而异,方式与上面的 500 错误相同。
456 466
457529 不是您的使用限制,也不会计入您的配额。467529 不是您的用量限制,也不会计入您的配额。
458 468
459**应该做什么:**469**应该做什么:**
460 470
474Request timed out484Request timed out
475```485```
476 486
477这可能在高负载期间或模型生成非常大的响应时发生。默认请求超时为 10 分钟。487这可能在高负载期间或模型生成非常大的响应时发生。默认请求超时时间为 10 分钟。
478 488
479**应该做什么:**489**应该做什么:**
480 490
486 No response from API496 No response from API
487</h3>497</h3>
488 498
489Claude Code 发送了流式请求,API 在第一个字节的截止时间内没有返回响应头,因此 Claude Code 中止了请求,而不是等待完整的 `API_TIMEOUT_MS` 请求超时(默认为 10 分钟)。Claude Code 最多再发送一次请求,如果[重试预算](#tune-retry-behavior)允许的话。当重试也没有得到回复时,该轮次以此消息结束,该消息显示每次尝试等待了多长时间。当您设置 [`CLAUDE_CODE_RETRY_WATCHDOG`](/docs/zh-CN/env-vars) 时,一次重试的上限不适用,Claude Code 在[调整重试行为](#tune-retry-behavior)中描述的预算下重试。499Claude Code 发送了流式请求,API 在第一个字节的截止时间内没有返回响应头,因此 Claude Code 中止了请求,而不是等待完整的 `API_TIMEOUT_MS` 请求超时时间(默认为 10 分钟)。Claude Code 最多再发送一次请求,如果[重试预算](#tune-retry-behavior)允许的话。当重试也没有得到回复时,该轮次以此消息结束,该消息显示每次尝试等待了多长时间。当您设置 [`CLAUDE_CODE_RETRY_WATCHDOG`](/docs/zh-CN/env-vars) 时,一次重试的上限不适用,Claude Code 在[调整重试行为](#tune-retry-behavior)中描述的预算下重试。
490 500
491```text theme={null}501```text theme={null}
492API Error: No response from API (waited 3m, then 10m on the retry). If a proxy or gateway on your network holds responses until they complete, raise API_TIMEOUT_MS or CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS to wait longer.502API Error: No response from API (waited 3m, then 10m on the retry). If a proxy or gateway on your network holds responses until they complete, raise API_TIMEOUT_MS or CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS to wait longer.
494 504
495Claude Code 分别为第一次尝试的等待响应头和重试的等待设置:505Claude Code 分别为第一次尝试的等待响应头和重试的等待设置:
496 506
497* **第一次尝试**:当您将其设置为 1 或更多时使用 [`CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS`](/docs/zh-CN/env-vars),限制在 10 秒到 30 分钟之间。否则 Claude Code 使用[流式空闲监视程序](/docs/zh-CN/network-config#streaming-idle-watchdogs)中列出的字节级监视程序超时,因此改变该超时的变量也会改变此等待。无论哪种方式,Claude Code 为请求体的每 32KB 添加一秒。507* **第一次尝试**:当您将其设置为 1 或更多时使用 [`CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS`](/docs/zh-CN/env-vars),限制在 10 秒到 30 分钟之间。否则 Claude Code 使用[流式空闲监视程序](/docs/zh-CN/network-config#streaming-idle-watchdogs)中列出的字节级监视程序超时时间,因此改变该超时时间的变量也会改变此等待。无论哪种方式,Claude Code 为请求体的每 32KB 添加一秒。
498* **重试**:比 `API_TIMEOUT_MS` 少一秒,默认略低于 10 分钟,以便重试可以超过保持响应直到生成完成的代理或网关。在 Amazon Bedrock 上,重试使用与第一次尝试相同的截止时间,消息显示一个持续时间而不是两个。508* **重试**:比 `API_TIMEOUT_MS` 少一秒,默认略低于 10 分钟,以便重试可以超过保持响应直到生成完成的代理或网关。在 Amazon Bedrock 上,重试使用与第一次尝试相同的截止时间,消息显示一个持续时间而不是两个。
499 509
500两个等待都不超过正 `API_TIMEOUT_MS` 少一秒,正 `API_TIMEOUT_MS` 低于 11 秒会关闭截止时间。字节级监视程序仅在响应头到达后才开始,因此在此之后停止发送字节的响应遵循[停滞流规则](#automatic-retries)而不是此截止时间。510两个等待都不超过正 `API_TIMEOUT_MS` 少一秒,正 `API_TIMEOUT_MS` 低于 11 秒会关闭截止时间。字节级监视程序仅在响应头到达后才开始,因此在此之后停止发送字节的响应遵循[停滞流规则](#automatic-retries)而不是此截止时间。
501 511
502**应该做什么:**512**应该做什么:**
503 513
504* 再次发送您的消息。您的原始消息仍在对话中,因此对于较长的提示,您可以输入 `try again` 而不是粘贴整个内容。514* 再次发送您的消息。您的原始消息仍在对话中,因此对于较长的提示词,您可以输入 `try again` 而不是粘贴整个内容。
505* 如果重复出现,将其视为[网络或代理问题](#unable-to-connect-to-api)。515* 如果重复出现,将其视为[网络或代理问题](#unable-to-connect-to-api)。
506* 如果您网络上的代理或网关保持响应直到完成,请提高 `API_TIMEOUT_MS` 以便重试等待更长时间。在 Amazon Bedrock 上,也提高 `CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS`。516* 如果您网络上的代理或网关保持响应直到完成,请提高 `API_TIMEOUT_MS` 以便重试等待更长时间。在 Amazon Bedrock 上,也提高 `CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS`。
507* 如果第一次尝试持续超时,然后重试成功,请提高 `CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS` 以便第一次尝试也等待足够长的时间。517* 如果第一次尝试持续超时,然后重试成功,请提高 `CLAUDE_STREAM_FIRST_BYTE_TIMEOUT_MS` 以便第一次尝试也等待足够长的时间。
508 518
509在 v2.1.242 之前,Claude Code 在未回复的流式请求失败之前等待完整的 `API_TIMEOUT_MS` 请求超时(默认为 10 分钟)。在 v2.1.261 之前,重试等待与第一次尝试相同的截止时间,消息没有显示持续时间。519在 v2.1.242 之前,Claude Code 在未回复的流式请求失败之前等待完整的 `API_TIMEOUT_MS` 请求超时时间(默认为 10 分钟)。在 v2.1.261 之前,重试等待与第一次尝试相同的截止时间,消息没有显示持续时间。
510 520
511<h3 id="the-response-above-may-be-incomplete">521<h3 id="the-response-above-may-be-incomplete">
512 The response above may be incomplete522 The response above may be incomplete
528* `Your computer went to sleep mid-response`:Claude Code 检测到您的计算机在响应流式传输时进入睡眠状态。一旦您的计算机唤醒,Claude Code 会将连接视为断开并停止从中读取。538* `Your computer went to sleep mid-response`:Claude Code 检测到您的计算机在响应流式传输时进入睡眠状态。一旦您的计算机唤醒,Claude Code 会将连接视为断开并停止从中读取。
529* `Part of the response never arrived`:流事件在 API 和 Claude Code 之间被丢弃,因此后来的事件引用了从未到达的内容。在 v2.1.281 之前,此情况以 `API Error: Content block not found` 结束轮次。539* `Part of the response never arrived`:流事件在 API 和 Claude Code 之间被丢弃,因此后来的事件引用了从未到达的内容。在 v2.1.281 之前,此情况以 `API Error: Content block not found` 结束轮次。
530* `The response stream was malformed`:为已完成的内容块到达了事件,或事件到达时已损坏。损坏的事件是指其数据不是有效 JSON、其内容缺失或其内容与事件类型不匹配的事件。在 v2.1.284 之前,当具有无效 JSON 的事件在 Claude 完成其思考、文本块或工具调用后到达时,解析器的原始错误(例如以 `API Error: JSON Parse error` 开头的错误)出现。540* `The response stream was malformed`:为已完成的内容块到达了事件,或事件到达时已损坏。损坏的事件是指其数据不是有效 JSON、其内容缺失或其内容与事件类型不匹配的事件。在 v2.1.284 之前,当具有无效 JSON 的事件在 Claude 完成其思考、文本块或工具调用后到达时,解析器的原始错误(例如以 `API Error: JSON Parse error` 开头的错误)出现。
531* `The response stopped arriving`:连接保持打开但停止传递数据,因此流式空闲监视程序中止了它。在 v2.1.222 之前,Claude Code 也可能在通过 `ANTHROPIC_BASE_URL` 或 `ANTHROPIC_AWS_BASE_URL` 到达的[网关](/docs/zh-CN/gateways)连接上报告此故障,同时服务器的保活 ping 仍在到达,因为它只在那里计算已解析的响应事件;升级会停止这些虚假超时。通过提供商基础 URL(如 `ANTHROPIC_BEDROCK_BASE_URL`)到达的网关不被字节监视程序包装;请参阅[流式空闲监视程序](/docs/zh-CN/network-config#streaming-idle-watchdogs)。541* `The response stopped arriving`:连接保持打开但停止传递数据,因此流式空闲监视程序中止了它。在 v2.1.222 之前,Claude Code 也可能在通过 `ANTHROPIC_BASE_URL` 或 `ANTHROPIC_AWS_BASE_URL` 到达的[网关](/docs/zh-CN/gateways)连接上报告此故障,同时服务器的保活 ping 仍在到达,因为它只在那里计算已解析的响应事件;升级会在这些路由上停止这些虚假超时。通过提供商基础 URL(如 `ANTHROPIC_BEDROCK_BASE_URL`)到达的网关不被字节监视程序包装;请参阅[流式空闲监视程序](/docs/zh-CN/network-config#streaming-idle-watchdogs)。
532 542
533在 v2.1.227 之前,`Connection lost mid-response` 读作 `Connection closed mid-response`,`The response stopped arriving` 读作 `Response stalled mid-stream`。543在 v2.1.227 之前,`Connection lost mid-response` 读作 `Connection closed mid-response`,`The response stopped arriving` 读作 `Response stalled mid-stream`。
534 544
541 551
542* 在响应的早期,Claude Code 要么重试故障,要么以不同的错误结束轮次。请参阅[自动重试](#automatic-retries)。552* 在响应的早期,Claude Code 要么重试故障,要么以不同的错误结束轮次。请参阅[自动重试](#automatic-retries)。
543* 当这些故障之一在 Claude 完成响应后到达时,Claude Code 保留完整响应并正常结束轮次,没有此通知。在 v2.1.222 之前,当连接在响应完成后断开或停滞时,Claude Code 显示此通知,并将轮次报告为错误,即使响应是完整的。553* 当这些故障之一在 Claude 完成响应后到达时,Claude Code 保留完整响应并正常结束轮次,没有此通知。在 v2.1.222 之前,当连接在响应完成后断开或停滞时,Claude Code 显示此通知,并将轮次报告为错误,即使响应是完整的。
544* 在[非交互式会话](/docs/zh-CN/headless)中,例如 `-p` 运行、[Agent SDK](/docs/zh-CN/agent-sdk/overview) 运行或[云会话](/docs/zh-CN/claude-code-on-the-web),当截断响应在主对话中且包含文本但没有工具调用时,您不必自己发送 `continue`:Claude Code 保留部分输出并提示 Claude 从停止的地方继续,最多连续三次。您只有在 Claude Code 用完这些继续后才会看到此通知。在 v2.1.246 之前,Claude Code 在第一次截断时以此通知结束非交互式轮次。554* 在[非交互式会话](/docs/zh-CN/headless)中,例如 `-p` 运行、[Agent SDK](/docs/zh-CN/agent-sdk/overview) 运行或[云端会话](/docs/zh-CN/claude-code-on-the-web),当截断响应在主对话中且包含文本但没有工具调用时,您不必自己发送 `continue`:Claude Code 保留部分输出并提示 Claude 从停止的地方继续,最多连续三次。您只有在 Claude Code 用完这些继续后才会看到此通知。在 v2.1.246 之前,Claude Code 在第一次截断时以此通知结束非交互式轮次。
545* 在[子代理](/docs/zh-CN/sub-agents#api-errors-in-subagents)中,无论会话是否交互式:当其截断响应包含文本但没有工具调用时,Claude Code 提示子代理继续。通知仅在这些继续用完后才成为子代理的最后一条消息。在 v2.1.257 之前,子代理在第一次截断时显示此通知。555* 在[子代理](/docs/zh-CN/sub-agents#api-errors-in-subagents)中,无论会话是否交互式:当其截断响应包含文本但没有工具调用时,Claude Code 提示子代理继续。通知仅在这些继续用完后才成为子代理的最后一条消息。在 v2.1.257 之前,子代理在第一次截断时显示此通知。
546 556
547**应该做什么:**557**应该做什么:**
548 558
549* 在交互式会话中,阅读屏幕上剩余的响应:Claude Code 保留 Claude 在错误前完成的每个块,但当轮次结束时丢弃中断的最后块,因此最后的句子或工具调用可能会丢失。回复 `continue` 以让 Claude 从其最后完成的块继续。559* 在交互式会话中,阅读屏幕上剩余的响应:Claude Code 保留 Claude 在错误前完成的每个块,但当轮次结束时丢弃中断的最后块,因此最后的句子或工具调用可能会丢失。回复 `continue` 以让 Claude 从其最后完成的块继续。
550* 在[非交互式模式](/docs/zh-CN/headless)(`-p`)中:560* 在[非交互模式](/docs/zh-CN/headless)(`-p`)中:
551 * 使用默认文本输出,Claude Code 打印它仍然从轮次早期保留的最后完成的文本块,然后是此消息。当它不保留任何内容时,Claude Code 仅打印此消息,例如因为 Claude Code 在轮次中间压缩了对话并清除了该文本。在 v2.1.219 之前,Claude Code 仅在 `-p` 文本输出中打印此消息并丢弃它已经生成的响应。561 * 使用默认文本输出,Claude Code 打印它仍然从轮次早期保留的最后完成的文本块,然后是此消息。当它不保留任何内容时,Claude Code 仅打印此消息,例如因为 Claude Code 在轮次中间压缩了对话并清除了该文本。在 v2.1.219 之前,Claude Code 仅在 `-p` 文本输出中打印此消息并丢弃它已经生成的响应。
552 * 使用 `--output-format json` 或 `stream-json`,Claude Code 在 `result` 字段中报告此消息。562 * 使用 `--output-format json` 或 `stream-json`,Claude Code 在 `result` 字段中报告此消息。
553 * 一旦连接稳定,要继续该轮次,请恢复会话并按照[继续对话](/docs/zh-CN/headless#continue-conversations)中的说明发送 `continue`。563 * 一旦连接稳定,要继续该轮次,请恢复会话并按照[继续对话](/docs/zh-CN/headless#continue-conversations)中的说明发送 `continue`。
556 Auto mode cannot determine the safety of an action566 Auto mode cannot determine the safety of an action
557</h3>567</h3>
558 568
559[auto mode](/docs/zh-CN/permission-modes#eliminate-prompts-with-auto-mode) 使用的模型无法对操作进行分类,因此 auto mode 没有自动批准该操作。您看到的消息取决于分类器如何失败。569[自动模式](/docs/zh-CN/permission-modes#eliminate-prompts-with-auto-mode)使用的模型无法对操作进行分类,因此自动模式没有自动批准该操作。您看到的消息取决于分类器如何失败。
560 570
561对工作目录内的读取、搜索和编辑会跳过分类器,因此它们在所有这些情况下都继续工作。571对工作目录内的读取、搜索和编辑会跳过分类器,因此它们在所有这些情况下都继续工作。
562 572
572 582
573**应该做什么:**583**应该做什么:**
574 584
575* 几秒后重试;Claude 看到相同的消息,通常会自动重试。暂时故障与 [auto mode 资格](/docs/zh-CN/permission-modes#eliminate-prompts-with-auto-mode)无关;您不需要更改设置585* 几秒后重试;Claude 看到相同的消息,通常会自动重试。暂时故障与[自动模式资格](/docs/zh-CN/permission-modes#eliminate-prompts-with-auto-mode)无关;您不需要更改设置
576* 如果重试持续失败,继续进行只读任务,稍后回到被阻止的操作586* 如果重试持续失败,继续进行只读任务,稍后回到被阻止的操作
577* 在 Amazon Bedrock 上,如果消息在每次重试时返回,请检查您的账户是否可以调用它指出的模型:对于标准 Amazon Bedrock 模型,确认您的 [IAM 策略](/docs/zh-CN/amazon-bedrock#iam-configuration)允许调用它;对于 Mantle 模型 ID,[联系您的 AWS 账户团队](/docs/zh-CN/amazon-bedrock#mantle-endpoint-errors)587* 在 Amazon Bedrock 上,如果消息在每次重试时返回,请检查您的账户是否可以调用它指出的模型:对于标准 Amazon Bedrock 模型,确认您的 [IAM 策略](/docs/zh-CN/amazon-bedrock#iam-configuration)允许调用它;对于 Mantle 模型 ID,[联系您的 AWS 账户团队](/docs/zh-CN/amazon-bedrock#mantle-endpoint-errors)
578 588
579当分类器请求失败是因为您的 OAuth 令牌过期或被另一个会话轮换时,Claude Code 刷新令牌并重试请求一次,因此例行令牌过期不会显示为此消息。在 v2.1.216 之前,过期或轮换的令牌会导致每个分类器请求失败,auto mode 会拒绝每个检查的操作,直到令牌被刷新。589当分类器请求失败是因为您的 OAuth 令牌过期或被另一个会话轮换时,Claude Code 刷新令牌并重试请求一次,因此常规的令牌过期不会显示为此消息。在 v2.1.216 之前,过期或轮换的令牌会导致每个分类器请求失败,自动模式会以此消息拒绝每个检查的操作,直到令牌被刷新。
580 590
581当分类器返回无法解析的响应时:591当分类器返回无法解析的响应时:
582 592
595Auto mode could not evaluate this action and is blocking it for safety — a safety check separate from auto mode blocked this request because of earlier conversation content — it isn't about the action itself — run with --debug for details605Auto mode could not evaluate this action and is blocking it for safety — a safety check separate from auto mode blocked this request because of earlier conversation content — it isn't about the action itself — run with --debug for details
596```606```
597 607
598Claude Code 拒绝该操作,但告诉 Claude 这不是对该操作不安全的判断,并继续进行其他任务而不是重试。这些拒绝不计入 [auto mode 的暂停阈值](/docs/zh-CN/permission-modes#when-auto-mode-falls-back)。在[非交互式](/docs/zh-CN/headless) `-p` 运行中,Claude Code 不会停止运行。Claude 接收的内容取决于它请求操作的位置:608Claude Code 拒绝该操作,但告诉 Claude 这不是对该操作不安全的判断,并继续进行其他任务而不是重试。这些拒绝不计入[自动模式的暂停阈值](/docs/zh-CN/permission-modes#when-auto-mode-falls-back)。在[非交互式](/docs/zh-CN/headless) `-p` 运行中,Claude Code 不会停止运行。Claude 接收的内容取决于它请求操作的位置:
599 609
600* 对于 `-p` 运行中没有 `--input-format stream-json` 的[后台子代理](/docs/zh-CN/sub-agents#run-subagents-in-foreground-or-background),Claude Code 返回包含 `Agent aborted: auto mode classifier request refused by the safety safeguard in headless mode` 的错误结果610* 对于 `-p` 运行中没有 `--input-format stream-json` 的[后台子代理](/docs/zh-CN/sub-agents#run-subagents-in-foreground-or-background),Claude Code 返回包含 `Agent aborted: auto mode classifier request refused by the safety safeguard in headless mode` 的错误结果
601* 在其他地方,包括交互式会话和 `-p` 运行的主对话,Claude Code 将该拒绝返回给 Claude611* 在其他地方,包括交互式会话和 `-p` 运行的主对话,Claude Code 将该拒绝返回给 Claude
602 612
603在 v2.1.225 之前,Claude Code 将这些拒绝计入暂停阈值,并返回与真正分类器块相同的拒绝消息。613在 v2.1.225 之前,Claude Code 将这些拒绝计入暂停阈值,并返回与真正分类器阻止相同的拒绝消息。
604 614
605**应该做什么:**615**应该做什么:**
606 616
607* 这不是对您的操作的决定。您对话中已有的内容在 auto mode 将对话发送给分类器时触发了 API 上的安全过滤器617* 这不是对您的操作的决定。您对话中已有的内容在自动模式将对话发送给分类器时触发了 API 上的安全过滤器
608* 重试无法帮助;相同的对话内容将再次触发过滤器618* 重试无法帮助;相同的对话内容将再次触发过滤器
609* 在交互式会话中,切换到不同的[权限模式](/docs/zh-CN/permission-modes),以便您可以在提示时批准该操作619* 在交互式会话中,切换到不同的[权限模式](/docs/zh-CN/permission-modes),以便您可以在提示时批准该操作
610* 开始一个新对话,不包含触发内容620* 开始一个新对话,不包含触发内容
617 627
618操作发生的情况取决于 Claude 请求它的位置:628操作发生的情况取决于 Claude 请求它的位置:
619 629
620* 在交互式会话中,auto mode 回退到该操作的正常权限提示,以便您可以手动批准或拒绝它630* 在交互式会话中,自动模式回退到该操作的正常权限提示,以便您可以手动批准或拒绝它
621* 对于[非交互式](/docs/zh-CN/headless) `-p` 运行中没有 `--input-format stream-json` 的[后台子代理](/docs/zh-CN/sub-agents#run-subagents-in-foreground-or-background),Claude Code 返回包含 `Agent aborted: auto mode classifier transcript exceeded context window in headless mode` 的错误结果,运行继续631* 对于[非交互式](/docs/zh-CN/headless) `-p` 运行中没有 `--input-format stream-json` 的[后台子代理](/docs/zh-CN/sub-agents#run-subagents-in-foreground-or-background),Claude Code 返回包含 `Agent aborted: auto mode classifier transcript exceeded context window in headless mode` 的错误结果,运行继续
622* 在 `-p` 运行中的其他地方,没有 [`--permission-prompt-tool`](/docs/zh-CN/cli-reference#cli-flags),没有提示可以回退到,因此操作不运行,运行继续632* 在 `-p` 运行中的其他地方,没有 [`--permission-prompt-tool`](/docs/zh-CN/cli-reference#cli-flags),没有提示可以回退到,因此操作不运行,运行继续
623 633
630 The server returned no safety verdict640 The server returned no safety verdict
631</h3>641</h3>
632 642
633在[服务器端分类器审查](/docs/zh-CN/permission-modes#server-side-classifier-review)下,当服务器对操作没有给出判决时,auto mode 拒绝该操作。当 Claude Code 可以确定一个类别时,拒绝会在括号中指出一个类别,例如 `(timed out)`:643在[服务器端分类器审查](/docs/zh-CN/permission-modes#server-side-classifier-review)下,当服务器对操作没有给出判决时,自动模式拒绝该操作。当 Claude Code 可以确定一个类别时,拒绝会在括号中指出一个类别,例如 `(timed out)`:
634 644
635```text theme={null}645```text theme={null}
636The server-side auto mode classifier gave no verdict (timed out), so auto mode cannot determine the safety of <tool>.646The server-side auto mode classifier gave no verdict (timed out), so auto mode cannot determine the safety of <tool>.
638 648
639消息的其余部分告诉 Claude 一次重试是否可以帮助。在某些这些拒绝之前,Claude Code 会等待,以便 Claude 的下一次尝试不会立即跟随。在交互式会话中等待期间,微调器显示 `Auto mode check unavailable` 和倒计时,按 `Esc` 会中断轮次。649消息的其余部分告诉 Claude 一次重试是否可以帮助。在某些这些拒绝之前,Claude Code 会等待,以便 Claude 的下一次尝试不会立即跟随。在交互式会话中等待期间,微调器显示 `Auto mode check unavailable` 和倒计时,按 `Esc` 会中断轮次。
640 650
641在连续十个响应都没有判决后,auto mode 停止轮次:651在连续十个响应都没有判决后,自动模式停止轮次:
642 652
643```text theme={null}653```text theme={null}
644Auto mode is unavailable — the server returned no safety verdict for the last 10 responses, so Claude stopped. Send a message to try again, or switch out of auto mode.654Auto mode is unavailable — the server returned no safety verdict for the last 10 responses, so Claude stopped. Send a message to try again, or switch out of auto mode.
646 656
647停止消息在每种会话中出现在不同的位置:657停止消息在每种会话中出现在不同的位置:
648 658
649* 在交互式会话中,消息作为警告出现在记录中,轮次结束659* 在交互式会话中,消息作为警告出现在会话记录中,轮次结束
650* 在[非交互式](/docs/zh-CN/headless) `-p` 运行中,运行结束并报告执行错误。使用默认文本输出,消息在 stderr 上打印。660* 在[非交互式](/docs/zh-CN/headless) `-p` 运行中,运行结束并报告执行错误。使用默认文本输出,消息在 stderr 上打印。
651* 当[子代理](/docs/zh-CN/sub-agents)达到限制时,子代理在完成之前停止,Claude 接收它生成的任何内容,并附带 auto mode 停止它的说明661* 当[子代理](/docs/zh-CN/sub-agents)达到限制时,子代理在完成之前停止,Claude 接收它生成的任何内容,并附带自动模式停止它的说明
652 662
653**应该做什么:**663**应该做什么:**
654 664
655* 发送另一条消息以让 Claude 重试。响应计数重新开始。665* 发送另一条消息以让 Claude 重试。响应计数重新开始。
656* 如果停止重复且您的请求通过[LLM 网关或代理](/docs/zh-CN/llm-gateway),检查它是否截断流式响应或重写它们。[服务器端分类器审查](/docs/zh-CN/permission-modes#server-side-classifier-review)说明哪种网关行为会导致拒绝,[网关兼容性指南](/docs/zh-CN/llm-gateway-protocol#feature-pass-through)列出了要保持不变的内容。666* 如果停止重复且您的请求通过[LLM 网关或代理](/docs/zh-CN/llm-gateway),检查它是否截断流式响应或重写它们。[服务器端分类器审查](/docs/zh-CN/permission-modes#server-side-classifier-review)说明哪种网关行为会导致拒绝,[网关兼容性指南](/docs/zh-CN/llm-gateway-protocol#feature-pass-through)列出了要保持不变的内容。
657* 在启动 Claude Code 之前设置 `CLAUDE_CODE_AUTO_MODE_SERVER=0` 以改用其自己的分类器请求。在 v2.1.281 之前,Claude Code 在直接连接到 Anthropic API 时不读取该变量。667* 在启动 Claude Code 之前设置 `CLAUDE_CODE_AUTO_MODE_SERVER=0` 以改用其自己的分类器请求。在 v2.1.281 之前,Claude Code 在直接连接到 Anthropic API 时不读取该变量。
658* 要自己批准操作,请改为[切换出 auto mode](/docs/zh-CN/permission-modes#switch-permission-modes)668* 要自己批准操作,请改为[切换出自动模式](/docs/zh-CN/permission-modes#switch-permission-modes)
659 669
660在 v2.1.280 之前,Claude Code 立即拒绝来自没有判决的响应的每个操作,从不停止轮次。670在 v2.1.280 之前,Claude Code 立即拒绝来自没有判决的响应的每个操作,从不停止轮次。
661 671
663 Agent terminated early due to an API error673 Agent terminated early due to an API error
664</h3>674</h3>
665 675
666[子代理](/docs/zh-CN/sub-agents)的 API 请求终止失败,例如因为达到了使用限制或服务器错误的重试用尽,因此子代理在完成其任务之前停止。此消息需要 Claude Code v2.1.199 或更高版本;在此之前,API 错误文本被返回给 Claude,就像它是子代理的结果一样。676[子代理](/docs/zh-CN/sub-agents)的 API 请求终止失败,例如因为达到了用量限制或服务器错误的重试用尽,因此子代理在完成其任务之前停止。此消息需要 Claude Code v2.1.199 或更高版本;在此之前,API 错误文本被返回给 Claude,就像它是子代理的结果一样。
667 677
668```text theme={null}678```text theme={null}
669Agent terminated early due to an API error: <error detail>679Agent terminated early due to an API error: <error detail>
671 681
672**应该做什么:**682**应该做什么:**
673 683
674* 将冒号后的错误详情与此页面上的其自己的部分匹配,例如[使用限制](#usage-limits)或[服务器错误](#server-errors),并按照该部分的步骤操作684* 将冒号后的错误详情与此页面上的其自己的部分匹配,例如[用量限制](#usage-limits)或[服务器错误](#server-errors),并按照该部分的步骤操作
675* 一旦底层错误清除,请要求 Claude 重试任务或[恢复子代理](/docs/zh-CN/sub-agents#resume-subagents)685* 一旦底层错误清除,请要求 Claude 重试任务或[恢复子代理](/docs/zh-CN/sub-agents#resume-subagents)
676 686
677当速率限制、过载或服务器错误中断已经生成文本输出的前台子代理时,Claude 接收该部分输出标记为不完整,而不是此错误。仅输出为工具调用的子代理也会收到此错误;在 v2.1.199 中,该形状返回了空的部分结果。请参阅[子代理中的 API 错误](/docs/zh-CN/sub-agents#api-errors-in-subagents)。687当速率限制、过载或服务器错误中断已经生成文本输出的前台子代理时,Claude 接收该部分输出标记为不完整,而不是此错误。仅输出为工具调用的子代理也会收到此错误;在 v2.1.199 中,该形状返回了空的部分结果。请参阅[子代理中的 API 错误](/docs/zh-CN/sub-agents#api-errors-in-subagents)。
697 707
698Claude Code 会阻止进一步的请求,直到消息中显示的重置时间。会话和周限制在所有模型中共享,因此切换模型不会恢复访问权限。Opus 和 Sonnet 限制各自仅适用于对该模型系列的请求,因此使用 `/model` 切换到该系列之外的模型可以继续工作。708Claude Code 会阻止进一步的请求,直到消息中显示的重置时间。会话和周限制在所有模型中共享,因此切换模型不会恢复访问权限。Opus 和 Sonnet 限制各自仅适用于对该模型系列的请求,因此使用 `/model` 切换到该系列之外的模型可以继续工作。
699 709
700在使用 claude.ai 订阅登录的交互式会话中,Claude Code 也可以在打开的会话中等待,并在重置后不久继续中断的任务。等待时,会话底部的一行显示 `Usage limit reached · continuing automatically at 3:45pm · esc to cancel`。在空提示处按 `Esc` 可取消等待。有关您看到的内容、如何开始或取消等待以及如何关闭自动继续的信息,请参阅 [Wait for a usage limit to reset](/docs/zh-CN/interactive-mode#wait-for-a-usage-limit-to-reset)。在 v2.1.234 之前,Claude Code 不提供此等待功能。710在使用 claude.ai 订阅登录的交互式会话中,Claude Code 也可以在打开的会话中等待,并在重置后不久继续中断的任务。有关您看到的内容、如何开始或取消等待以及如何关闭自动继续的信息,请参阅 [Wait for a usage limit to reset](/docs/zh-CN/interactive-mode#wait-for-a-usage-limit-to-reset)。在 v2.1.234 之前,Claude Code 不提供此等待功能。
701 711
702使用量同时计入会话和周额度。单次大量活动突发(例如大型工作流扇出)可能会在会话窗口重置之前耗尽周额度。712使用量同时计入会话和周额度。单次大量活动突发(例如大型工作流扇出)可能会在会话窗口重置之前耗尽周额度。
703 713
885 身份验证错误895 身份验证错误
886</h2>896</h2>
887 897
888这些错误意味着 Claude Code 无法向 API 证明您的身份。随时运行 `/status` 查看当前活跃的凭证。898这些错误表示 Claude Code 无法向 API 证明您的身份。您可以随时运行 `/status` 查看当前生效的凭据。
889 899
890<h3 id="not-logged-in">900<h3 id="not-logged-in">
891 未登录901 未登录
892</h3>902</h3>
893 903
894此会话没有可用的有效凭证。904此会话没有可用的有效凭据。
895 905
896```text theme={null}906```text theme={null}
897Not logged in · Please run /login907Not logged in · Please run /login
898```908```
899 909
900在 Claude Desktop 应用运行的会话中,例如 Code 标签页或 Cowork,消息读作 `Authentication required · Sign in again to continue`,您从应用中再次登录。910在由 Claude Desktop 应用运行的会话中(例如 Code 标签页或 Cowork),消息显示为 `Authentication required · Sign in again to continue`,您需要在应用中重新登录。
901 911
902**应该做什么:**912如果您在另一个使用相同[配置目录](/docs/zh-CN/claude-directory)的 Claude Code 窗口中使用 claude.ai 账户登录,显示此消息的交互式会话会自动开始使用该登录。您无需重启会话。
913
914在 macOS 上的 v2.1.286 之前版本中,您在另一个窗口登录后,该会话可能仍会继续显示此消息。在这些版本中,请重启显示此消息的会话。
903 915
904* 运行 `/login` 以使用您的 Claude 订阅或 Console 账户进行身份验证916**解决方法:**
905* 如果您期望使用环境变量进行身份验证,请确认 `ANTHROPIC_API_KEY` 已在启动 `claude` 的 shell 中设置并导出
906* 对于无法进行交互式登录的 CI 或自动化,配置一个 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本,在启动时获取密钥
907* 查看 [身份验证优先级](/docs/zh-CN/authentication#authentication-precedence) 以了解当存在多个凭证时 Claude Code 使用哪个凭证
908 917
909如果您被重复提示登录,请参阅 [未登录或令牌过期](/docs/zh-CN/troubleshoot-install#not-logged-in-or-token-expired) 了解系统时钟检查和 macOS 凭证存储恢复步骤。918* 运行 `/login`,使用您的 Claude 订阅或 Console 账户进行身份验证
919* 如果您原本希望通过环境变量进行身份验证,请确认在启动 `claude` 的 shell 中已设置并导出 `ANTHROPIC_API_KEY`
920* 对于无法进行交互式登录的 CI 或自动化场景,请配置一个在启动时获取密钥的 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本
921* 请参阅[身份验证优先级](/docs/zh-CN/authentication#authentication-precedence),了解存在多个凭据时 Claude Code 使用哪一个
922
923如果系统反复提示您登录,请参阅[未登录或令牌已过期](/docs/zh-CN/troubleshoot-install#not-logged-in-or-token-expired),了解系统时钟检查以及 macOS 凭据存储的恢复步骤。
910 924
911<h3 id="could-not-resolve-authentication-method">925<h3 id="could-not-resolve-authentication-method">
912 无法解析身份验证方法926 无法确定身份验证方法
913</h3>927</h3>
914 928
915会话到达 API 客户端时没有任何凭证。[后台会话](/docs/zh-CN/agent-view) 和云会话在 worker 启动时没有凭证时显示此消息。交互式、`-p` 和 Agent SDK 运行报告与 [未登录](#not-logged-in) 相同的条件,并仅将此字符串写入其调试日志,因此如果您在那里找到它,请改为遵循该条目。929会话在没有任何凭据的情况下到达了 API 客户端。当工作进程在没有凭据的情况下启动时,[后台会话](/docs/zh-CN/agent-view)和云端会话会显示此消息。交互式运行、`-p` 运行和 Agent SDK 运行会将同样的情况报告为[未登录](#not-logged-in),并且只将此字符串写入调试日志,因此如果您是在调试日志中发现的,请改为按照该条目操作。
916 930
917```text theme={null}931```text theme={null}
918Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted932Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted
919```933```
920 934
921在当前版本上,该错误意味着 worker 进程没有可用的凭证。在 v2.1.174 之前,分配给空闲预初始化 worker 的后台会话即使配置了有效凭证也可能以这种方式失败。在 v2.1.176 之前,在被声明之前处于空闲状态的云会话也可能失败。升级以恢复。935在当前版本中,此错误表示工作进程没有可用的凭据。在 v2.1.174 之前,分配给空闲的预初始化工作进程的后台会话即使已配置有效凭据,也可能以这种方式失败。在 v2.1.176 之前,在被认领前处于空闲状态的云端会话也可能出现这种情况。升级即可恢复。
922 936
923**应该做什么:**937**解决方法:**
924 938
925* 如果这出现在后台或云会话中且您的凭证已配置,请升级到 v2.1.176 或更高版本939* 如果此错误出现在后台会话或云端会话中,且您的凭据已经配置好,请升级到 v2.1.176 或更高版本
926* 确认 `ANTHROPIC_API_KEY`、`CLAUDE_CODE_OAUTH_TOKEN` 或您的云提供商凭证已在启动 worker 的环境中设置,而不仅仅在您的交互式 shell 中940* 确认 `ANTHROPIC_API_KEY`、`CLAUDE_CODE_OAUTH_TOKEN` 或您的云服务提供商凭据已在启动工作进程的环境中设置,而不仅仅是在您的交互式 shell 中设置
927* 对于 Agent SDK,请参阅 [快速入门中的身份验证设置](/docs/zh-CN/agent-sdk/quickstart#setup)941* 对于 Agent SDK,请参阅[快速入门中的身份验证设置](/docs/zh-CN/agent-sdk/quickstart#setup)
928* 在同一环境中的交互式会话中运行 `/status` 以确认哪个凭证源可解析942* 在同一环境中的交互式会话里运行 `/status`,确认解析到的是哪个凭据来源
929 943
930<h3 id="invalid-api-key">944<h3 id="invalid-api-key">
931 无效的 API 密钥945 API 密钥无效
932</h3>946</h3>
933 947
934`ANTHROPIC_API_KEY` 环境变量或 `apiKeyHelper` 脚本返回了 API 拒绝的密钥,或 Claude Code 在发送前阻止了来自 `ANTHROPIC_API_KEY` 的密钥。948`ANTHROPIC_API_KEY` 环境变量或 `apiKeyHelper` 脚本返回了一个被 API 拒绝的密钥,或者 Claude Code 在发送前拦截了来自 `ANTHROPIC_API_KEY` 的密钥。
935 949
936```text theme={null}950```text theme={null}
937Invalid API key · Fix external API key951Invalid API key · Fix external API key
938```952```
939 953
940当消息在 `Fix external API key` 之后继续,并带有描述如 `Invalid X-Api-Key header value from ANTHROPIC_API_KEY: it contains a line break at character 41 (120 characters on 2 lines).` 时,API 从未看到该密钥。Claude Code 发现了 HTTP 标头无法传输的字符,并在发送前停止了请求。请参阅 [无效的请求标头值](#invalid-request-header-value) 了解如何读取描述并修复该值。954如果消息在 `Fix external API key` 之后还附有一段描述,例如 `Invalid X-Api-Key header value from ANTHROPIC_API_KEY: it contains a line break at character 41 (120 characters on 2 lines).`,则说明 API 从未收到该密钥。Claude Code 发现了一个 HTTP 标头无法承载的字符,并在发送前停止了请求。请参阅[请求标头值无效](#invalid-request-header-value),了解如何解读该描述并修正该值。
941 955
942**应该做什么:**956**解决方法:**
943 957
944* 检查拼写错误并确认密钥未在 [Console](https://platform.claude.com/settings/keys) 中被撤销958* 检查是否有拼写错误,并在 [Console](https://platform.claude.com/settings/keys) 中确认该密钥未被撤销
945* 在同一 shell 中,运行 `env | grep ANTHROPIC`,或在 PowerShell 中运行 `Get-ChildItem Env:ANTHROPIC*`。direnv、dotenv shell 插件和 IDE 终端等工具可以从项目中的 `.env` 文件加载过时的密钥,而无需您显式设置它959* 在同一个 shell 中运行 `env | grep ANTHROPIC`,或在 PowerShell 中运行 `Get-ChildItem Env:ANTHROPIC*`。direnv、dotenv shell 插件以及 IDE 终端等工具可能会从项目中的 `.env` 文件加载过时的密钥,而您并未显式设置它。
946* 取消设置 `ANTHROPIC_API_KEY` 并运行 `/login` 以改用订阅身份验证960* 取消设置 `ANTHROPIC_API_KEY` 并运行 `/login`,改用订阅身份验证
947* 如果密钥来自 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本,请直接运行该脚本以确认它在 stdout 上打印有效密钥961* 如果密钥来自 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本,请直接运行该脚本,确认它在 stdout 上输出了有效的密钥
948* 运行 `/status` 以确认 Claude Code 实际使用的凭证源962* 运行 `/status`,确认 Claude Code 实际使用的是哪个凭据来源
949 963
950<h3 id="your-apikeyhelper-script-is-failing">964<h3 id="your-apikeyhelper-script-is-failing">
951 您的 apiKeyHelper 脚本失败965 您的 apiKeyHelper 脚本运行失败
952</h3>966</h3>
953 967
954Claude Code 运行了您的 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 设置中的命令,但没有获得密钥。没有密钥,请求会到达 API,并带有占位符凭证,API 会以 `401` 拒绝它。终端中的 `Authentication` 面板显示发生了以下哪种情况:968Claude Code 运行了您的 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 设置中的命令,但没有得到密钥。没有密钥时,请求会携带一个占位凭据到达 API,API 会以 `401` 拒绝它。终端中的 `Authentication` 面板会显示发生了以下哪种情况:
955 969
956* 命令以错误退出或超时970* 命令以错误退出或超时
957* 命令未向 stdout 打印任何内容971* 命令没有向 stdout 输出任何内容
958* 命令打印了除密钥之外的内容,例如登录横幅或日志行。该面板显示 `returned output that cannot be used as an API key` 并说明了问题所在,而不重复输出。在 v2.1.227 之前,Claude Code 发送命令打印的任何内容,在修剪周围空格后。972* 命令输出了密钥以外的内容,例如登录横幅或日志行。面板会显示 `returned output that cannot be used as an API key` 并说明问题所在,但不会重复输出内容。在 v2.1.227 之前,Claude Code 会在去除首尾空白后发送命令输出的任何内容。
959 973
960```text theme={null}974```text theme={null}
961Your apiKeyHelper script is failing · This usually means you need to re-authenticate with your provider · Run /status to see the script's error output975Your apiKeyHelper script is failing · This usually means you need to re-authenticate with your provider · Run /status to see the script's error output
962```976```
963 977
964在 [非交互式模式](/docs/zh-CN/headless) 中,stderr 也带有具体原因,前缀为 `apiKeyHelper failed:`。978在[非交互模式](/docs/zh-CN/headless)下,stderr 也会带有具体原因,前缀为 `apiKeyHelper failed:`。
965 979
966Claude Code 重新运行脚本并在显示此消息之前最多重试请求两次,因此故障在三次尝试内出现。在 v2.1.208 之前,Claude Code 花费完整的 [重试预算](#automatic-retries) 使用占位符凭证重新发送请求,然后报告通用 `401` 身份验证错误而不是脚本故障。980在显示此消息之前,Claude Code 会重新运行脚本并最多再重试请求两次,因此失败会在三次尝试内显现。在 v2.1.208 之前,Claude Code 会用完全部[重试预算](#automatic-retries),用占位凭据反复重新发送请求,然后报告一个通用的 `401` 身份验证错误,而不是脚本失败。
967 981
968运行 `/login` 在这里没有帮助:只要设置存在,helper 的输出 [优先于](/docs/zh-CN/authentication#authentication-precedence) 保存的登录。982此时运行 `/login` 没有帮助:只要该设置存在,helper 的输出就[优先于](/docs/zh-CN/authentication#authentication-precedence)已保存的登录。
969 983
970**应该做什么:**984**解决方法:**
971 985
972* 直接在您的 shell 中运行在 `apiKeyHelper` 中配置的命令以重现故障986* 在您的 shell 中直接运行 `apiKeyHelper` 中配置的命令,以复现该失败
973* 如果命令报告会话过期,请使用您的凭证提供商重新身份验证,例如再次登录您的 SSO 或密钥保管库987* 如果命令报告会话已过期,请向您的凭据提供方重新进行身份验证,例如重新登录您的 SSO 或密钥保管库
974* 修复命令,使其仅将密钥打印到 stdout,作为单个可打印 ASCII 令牌,最多 16,384 个字符,并以代码 0 退出。请参阅 [使用 apiKeyHelper 轮换凭证](/docs/zh-CN/llm-gateway-connect#rotate-credentials-with-apikeyhelper) 了解工作设置。988* 修正命令,使其只向 stdout 输出密钥(一个由可打印 ASCII 字符组成、最多 16,384 个字符的单一令牌),并以退出码 0 退出。请参阅[使用 apiKeyHelper 轮换凭据](/docs/zh-CN/llm-gateway-connect#rotate-credentials-with-apikeyhelper)了解可用的设置方式。
975* 运行 `/status` 查看故障并确认 `apiKeyHelper` 是活跃凭证源。`apiKeyHelper` 行显示 `Failing` 以及最后一次故障的详细信息,例如退出代码和命令的错误输出,并在下一次成功运行后消失。在 v2.1.274 之前,`/status` 仅显示凭证源,而不是故障。989* 运行 `/status` 查看失败情况,并确认 `apiKeyHelper` 是当前生效的凭据来源。`apiKeyHelper` 行会显示 `Failing` 以及上一次失败的详细信息,例如退出码和命令的错误输出,并会在下一次成功运行后消失。在 v2.1.274 之前,`/status` 只显示凭据来源,不显示失败情况。
976* 每次命令失败时,其退出代码和错误输出也会出现在终端中的 `Authentication` 面板中。在 v2.1.212 之前,该面板的标题为 `Cloud authentication`。990* 每次命令失败时,其退出码和错误输出也会显示在终端的 `Authentication` 面板中。在 v2.1.212 之前,该面板的标题为 `Cloud authentication`。
977 991
978<h3 id="invalid-request-header-value">992<h3 id="invalid-request-header-value">
979 无效的请求标头值993 请求标头值无效
980</h3>994</h3>
981 995
982Claude Code 即将作为请求标头发送的值包含 HTTP 标头无法传输的字符:换行符、NUL 字节或 `U+00FF` 以上的字符,例如弯引号或零宽空格。Claude Code 在发送任何内容之前停止请求,并命名要修复的变量或设置。通常的原因是从文档或聊天粘贴的凭证,其中包含不可见字符或杂散换行符。996Claude Code 即将作为请求标头发送的某个值包含 HTTP 标头无法承载的字符:换行符、NUL 字节,或 `U+00FF` 以上的字符(例如弯引号或零宽空格)。Claude Code 会在发送任何内容之前停止请求,并指出需要修正的变量或设置。常见原因是从文档或聊天中粘贴的凭据带有不可见字符或多余的换行符。
983 997
984Claude Code 在直接向 Claude API 或通过 [LLM 网关](/docs/zh-CN/llm-gateway) 发送请求时运行此检查。在第三方云提供商(如 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock))上,Claude Code 在发送前不运行它。998当 Claude Code 直接或通过 [LLM 网关](/docs/zh-CN/llm-gateway)向 Claude API 发送请求时,会执行此检查。在 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock) 等第三方云服务提供商上,Claude Code 不会在发送前执行此检查。
985 999
986```text theme={null}1000```text theme={null}
987Invalid auth token · Fix external auth token1001Invalid auth token · Fix external auth token
989Invalid request header from the environment · Fix the environment variable1003Invalid request header from the environment · Fix the environment variable
990```1004```
991 1005
992消息的第一部分取决于坏值来自何处:1006消息的第一部分取决于错误值的来源:
993 1007
994* `Invalid auth token`:来自 [`ANTHROPIC_AUTH_TOKEN`](/docs/zh-CN/env-vars) 或 [`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 的持有者令牌1008* `Invalid auth token`:来自 [`ANTHROPIC_AUTH_TOKEN`](/docs/zh-CN/env-vars) 或 [`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 的 bearer 令牌
995* `Invalid ANTHROPIC_CUSTOM_HEADERS`:您在 [`ANTHROPIC_CUSTOM_HEADERS`](/docs/zh-CN/env-vars) 中设置的标头名称或值。描述计算哪个 `Name: Value` 对有问题,例如 `distinct header 2 of 3 parsed from ANTHROPIC_CUSTOM_HEADERS`,而不重复名称或值,因为您选择了两者。1009* `Invalid ANTHROPIC_CUSTOM_HEADERS`:您在 [`ANTHROPIC_CUSTOM_HEADERS`](/docs/zh-CN/env-vars) 中设置的标头名称或值。描述会指出出错的是第几个 `Name: Value` 对,例如 `distinct header 2 of 3 parsed from ANTHROPIC_CUSTOM_HEADERS`,但不会重复名称或值,因为两者都是您自己设定的。
996* `Invalid request header from the environment`:Claude Code 从另一个环境变量(如 `CLAUDE_AGENT_SDK_CLIENT_APP`)复制到请求标头中的值。描述命名要修复的变量。1010* `Invalid request header from the environment`:Claude Code 从另一个环境变量(例如 `CLAUDE_AGENT_SDK_CLIENT_APP`)复制到请求标头中的值。描述会指出需要修正的变量。
997 1011
998Claude Code 将此检查捕获的坏 `ANTHROPIC_API_KEY` 报告为 [无效的 API 密钥](#invalid-api-key),具有相同的尾部描述。它将坏的保存 `/login` 凭证报告为 [未登录](#not-logged-in);运行 `/login` 以保存新凭证。[`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本的输出永远不会到达此检查:Claude Code 在脚本运行时验证它,并且输出 HTTP 标头无法传输的失败会导致 [您的 apiKeyHelper 脚本失败](#your-apikeyhelper-script-is-failing)。1012此检查捕获到的错误 `ANTHROPIC_API_KEY` 会被 Claude Code 报告为 [API 密钥无效](#invalid-api-key),并附带同样的尾部描述。错误的已保存 `/login` 凭据则会被报告为[未登录](#not-logged-in);运行 `/login` 保存一个新的凭据即可。[`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 脚本的输出永远不会进入此检查:Claude Code 在脚本运行时就会对其进行验证,HTTP 标头无法承载的输出会以[您的 apiKeyHelper 脚本运行失败](#your-apikeyhelper-script-is-failing)的形式失败。
999 1013
1000在第二个 `·` 之后,消息描述问题,如以下完整示例:1014在第二个 `·` 之后,消息会描述问题,完整示例如下:
1001 1015
1002```text theme={null}1016```text theme={null}
1003Invalid auth token · Fix external auth token · Invalid Authorization header value from ANTHROPIC_AUTH_TOKEN: it contains a line break at character 41 (120 characters on 2 lines).1017Invalid auth token · Fix external auth token · Invalid Authorization header value from ANTHROPIC_AUTH_TOKEN: it contains a line break at character 41 (120 characters on 2 lines).
1004```1018```
1005 1019
1006位置从 1 开始计算字符。描述由固定短语和字符计数构建,因此它永远不包括值本身。它仅在字符是众所周知的不可见或排版字符(如字节顺序标记、零宽空格或弯引号)时命名该字符,并将其他任何内容报告为 `a non-ASCII character`。1020位置按字符计数,从 1 开始。描述由固定短语和字符计数组成,因此永远不会包含值本身。只有当问题字符是众所周知的不可见字符或排版字符(例如字节顺序标记、零宽空格或弯引号)时,描述才会指出该字符,其他字符一律报告为 `a non-ASCII character`。
1007 1021
1008**应该做什么:**1022**解决方法:**
1009 1023
1010* 重新设置消息命名的变量或设置,重新输入报告位置周围的字符,而不是从同一来源再次粘贴1024* 重新设置消息中指出的变量或设置,手动重新输入所报告位置附近的字符,而不是再次从同一来源粘贴
1011* 对于 `ANTHROPIC_CUSTOM_HEADERS`,每行保留一个 `Name: Value` 对,并重写消息计数的对1025* 对于 `ANTHROPIC_CUSTOM_HEADERS`,每行保留一个 `Name: Value` 对,并重写消息所指出的那一对
1012* 运行 `/status` 以确认哪个凭证源处于活跃状态1026* 运行 `/status`,确认当前生效的凭据来源
1013 1027
1014<h3 id="this-organization-has-been-disabled">1028<h3 id="this-organization-has-been-disabled">
1015 此组织已被禁用1029 此组织已被停用
1016</h3>1030</h3>
1017 1031
1018Claude Code 正在使用来自已禁用 Console 组织的过时 `ANTHROPIC_API_KEY`。当您有保存的订阅登录时,密钥会覆盖它。1032Claude Code 正在使用来自已停用 Console 组织的过时 `ANTHROPIC_API_KEY`。当您有已保存的订阅登录时,该密钥会覆盖它。
1019 1033
1020```text theme={null}1034```text theme={null}
1021Your ANTHROPIC_API_KEY belongs to a disabled organization · Unset the environment variable to use your subscription instead1035Your ANTHROPIC_API_KEY belongs to a disabled organization · Unset the environment variable to use your subscription instead
1023API Error: 400 ... This organization has been disabled.1037API Error: 400 ... This organization has been disabled.
1024```1038```
1025 1039
1026`·` 之后的提示取决于您保存的凭证:当存储的 `/login` 可以在您取消设置密钥后接管时出现第一种形式,当密钥是您唯一的凭证时出现第二种形式。1040`·` 之后的提示取决于您已保存的凭据:当您取消设置该密钥后有已存储的 `/login` 可以接替时,显示第一种形式;当该密钥是您唯一的凭据时,显示第二种形式。
1027 1041
1028环境变量优先于 `/login`,因此在您的 shell 配置文件中导出或从 `.env` 文件加载的密钥即使您有有效的 Pro 或 Max 订阅也会被使用。在非交互式模式 (`-p`) 中,当存在密钥时始终使用该密钥。1042环境变量优先于 `/login`,因此即使您拥有可用的 Pro 或 Max 订阅,在 shell 配置文件中导出或从 `.env` 文件加载的密钥仍会被使用。在非交互模式(`-p`)下,只要存在该密钥,就总会使用它。
1029 1043
1030**应该做什么:**1044**解决方法:**
1031 1045
1032* 在当前 shell 中取消设置 `ANTHROPIC_API_KEY` 并从您的 shell 配置文件中删除它,然后重新启动 `claude`1046* 在当前 shell 中取消设置 `ANTHROPIC_API_KEY`,并将其从 shell 配置文件中删除,然后重新启动 `claude`
1033* 如果消息说 `Update or unset`,您没有保存的登录可以回退。取消设置密钥并运行 `/login`,或将密钥替换为来自活跃 Console 组织的密钥。1047* 如果消息显示 `Update or unset`,说明您没有可回退的已保存登录。请取消设置该密钥并运行 `/login`,或将其替换为来自活跃 Console 组织的密钥。
1034* 之后运行 `/status` 以确认活跃凭证是您的订阅1048* 之后运行 `/status`,确认当前生效的凭据是您的订阅
1035* 如果未设置环境变量且错误仍然存在,请联系支持或使用不同账户登录。1049* 如果没有设置任何环境变量但错误仍然存在,请联系支持团队或使用其他账户登录。
1036 1050
1037<h3 id="your-organization-has-disabled-api-key-authentication">1051<h3 id="your-organization-has-disabled-api-key-authentication">
1038 您的组织已禁用 API 密钥身份验证1052 您的组织已禁用 API 密钥身份验证
1039</h3>1053</h3>
1040 1054
1041此消息需要 Claude Code v2.1.169 或更高版本。您的 Console 组织的管理员已关闭 API 密钥身份验证,因此 API 拒绝 Claude Code 正在发送的密钥。`·` 之后的恢复提示因密钥来自何处而异:1055此消息需要 Claude Code v2.1.169 或更高版本。您的 Console 组织管理员已关闭 API 密钥身份验证,因此 API 会拒绝 Claude Code 发送的密钥。`·` 之后的恢复提示因密钥来源而异:
1042 1056
1043```text theme={null}1057```text theme={null}
1044Your organization has disabled API key authentication · Run /login to sign in with your claude.ai account1058Your organization has disabled API key authentication · Run /login to sign in with your claude.ai account
1048Your organization has disabled API key authentication · Sign in again with your claude.ai account1062Your organization has disabled API key authentication · Sign in again with your claude.ai account
1049```1063```
1050 1064
1051最后一种形式出现在 Claude Desktop 应用运行的会话中,例如 Code 标签页或 Cowork,您从应用中再次登录。1065最后一种形式出现在由 Claude Desktop 应用运行的会话中(例如 Code 标签页或 Cowork),此时您需要在应用中重新登录。
1052 1066
1053环境变量和 `apiKeyHelper` 优先于 `/login`,因此仅运行 `/login` 在任一仍在提供密钥时没有帮助。请参阅 [身份验证优先级](/docs/zh-CN/authentication#authentication-precedence)。1067环境变量和 `apiKeyHelper` 优先于 `/login`,因此只要其中任何一个仍在提供密钥,单独运行 `/login` 是没有帮助的。请参阅[身份验证优先级](/docs/zh-CN/authentication#authentication-precedence)。
1054 1068
1055**应该做什么:**1069**解决方法:**
1056 1070
1057* 如果消息命名 `ANTHROPIC_API_KEY`,在当前 shell 中取消设置它并从您的 shell 配置文件或 `.env` 文件中删除它,然后重新启动 `claude`1071* 如果消息中提到 `ANTHROPIC_API_KEY`,请在当前 shell 中取消设置它,并将其从 shell 配置文件或 `.env` 文件中删除,然后重新启动 `claude`
1058* 如果消息命名 `apiKeyHelper`,从您的 `settings.json` 中删除 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 设置1072* 如果消息中提到 `apiKeyHelper`,请从您的 `settings.json` 中删除 [`apiKeyHelper`](/docs/zh-CN/settings-reference#apikeyhelper) 设置
1059* 运行 `/login` 以使用您的 claude.ai 账户登录1073* 运行 `/login`,使用您的 claude.ai 账户登录
1060* 之后运行 `/status` 以确认活跃凭证是您的订阅而不是 API 密钥1074* 之后运行 `/status`,确认当前生效的凭据是您的订阅而不是 API 密钥
1061* 如果您需要 API 密钥身份验证用于自动化,请要求您的组织管理员在 Console 中重新启用它1075* 如果您的自动化流程需要 API 密钥身份验证,请让组织管理员在 Console 中重新启用它
1062 1076
1063<h3 id="your-organization-has-disabled-claude-subscription-access">1077<h3 id="your-organization-has-disabled-claude-subscription-access">
1064 您的组织已禁用 Claude 订阅访问1078 您的组织已禁用 Claude 订阅访问
1065</h3>1079</h3>
1066 1080
1067您的 Claude 组织不允许使用订阅登录登录 Claude Code。使用同一账户再次运行 `/login` 会返回相同的错误。1081您的 Claude 组织不允许使用订阅登录来登录 Claude Code。使用同一账户再次运行 `/login` 会返回相同的错误。
1068 1082
1069```text theme={null}1083```text theme={null}
1070Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access1084Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access
1071```1085```
1072 1086
1073这是服务器端组织设置,因此无法从本地设置、环境变量或 CLI 标志覆盖。1087这是服务器端的组织设置,因此无法通过本地设置、环境变量或 CLI 标志覆盖。
1074 1088
1075Agent SDK 和 `-p` 非交互式模式将此显示为 `oauth_org_not_allowed` 错误代码。1089Agent SDK 和 `-p` 非交互模式会将其呈现为 `oauth_org_not_allowed` 错误代码。
1076 1090
1077**应该做什么:**1091**解决方法:**
1078 1092
1079* 要求您的管理员为您的组织启用 Claude Code 访问1093* 请管理员为您的组织启用 Claude Code 访问权限
1080* 使用 Console API 密钥而不是您的订阅进行身份验证。请参阅 [Claude Console 身份验证](/docs/zh-CN/authentication#claude-console-authentication) 了解设置。1094* 改用 Console API 密钥而不是订阅进行身份验证。设置方法请参阅 [Claude Console 身份验证](/docs/zh-CN/authentication#claude-console-authentication)。
1081* 如果您是管理员且看不到启用访问的选项,请联系 [Anthropic 支持](https://support.claude.com)1095* 如果您是管理员但找不到启用访问的选项,请联系 [Anthropic 支持](https://support.claude.com)
1082 1096
1083<h3 id="routines-are-disabled-by-your-organizations-policy">1097<h3 id="routines-are-disabled-by-your-organizations-policy">
1084 例程被您的组织的策略禁用1098 Routine 已被您组织的策略禁用
1085</h3>1099</h3>
1086 1100
1087您的 Team 或 Enterprise 组织中的所有者已在组织级别关闭例程。当您尝试创建或运行例程时会出现错误,例如从 [Routines](/docs/zh-CN/routines) UI on claude.ai/code。在 Claude Code v2.1.227 或更高版本上,相同的设置也 [隐藏 `/schedule`](/docs/zh-CN/routines#troubleshooting) 在 CLI 中。1101您所在的 Team 或 Enterprise 组织中的 Owner 已在组织级别关闭了 Routine。当您尝试创建或运行 Routine 时(例如通过 claude.ai/code 上的 [Routines](/docs/zh-CN/routines) 界面),会出现此错误。在 Claude Code v2.1.227 或更高版本中,同一设置还会在 CLI 中[隐藏 `/schedule`](/docs/zh-CN/routines#troubleshooting)。
1088 1102
1089```text theme={null}1103```text theme={null}
1090Routines are disabled by your organization's policy.1104Routines are disabled by your organization's policy.
1091```1105```
1092 1106
1093这是服务器端设置,因此无法从本地设置、环境变量或 CLI 标志覆盖。1107这是服务器端设置,因此无法通过本地设置、环境变量或 CLI 标志覆盖。
1094 1108
1095**应该做什么:**1109**解决方法:**
1096 1110
1097* 要求您的组织中的所有者在 [claude.ai/admin-settings/claude-code](https://claude.ai/admin-settings/claude-code) 启用 **Routines** 切换1111* 请您组织中的 Owner 在 [claude.ai/admin-settings/claude-code](https://claude.ai/admin-settings/claude-code) 启用 **Routines** 开关
1098* 对于不需要组织级例程的一次性计划工作,请参阅 [计划任务](/docs/zh-CN/scheduled-tasks)1112* 对于不需要组织级 Routine 的一次性定时工作,请参阅[定时任务](/docs/zh-CN/scheduled-tasks)
1099 1113
1100<h3 id="remote-control-requires-the-anthropic-api">1114<h3 id="remote-control-requires-the-anthropic-api">
1101 Remote Control 需要 Anthropic API1115 Remote Control 需要 Anthropic API
1102</h3>1116</h3>
1103 1117
1104会话不是直接与 Anthropic API 通信,因此 [Remote Control](/docs/zh-CN/remote-control) 需要。1118该会话没有直接与 Anthropic API 通信,而这是 [Remote Control](/docs/zh-CN/remote-control) 所必需的。
1105 1119
1106```text theme={null}1120```text theme={null}
1107Remote Control is only available when using Claude via api.anthropic.com. CLAUDE_CODE_USE_BEDROCK is set, so this session is using Amazon Bedrock — unset it (or run in a shell without it) to use Remote Control.1121Remote Control is only available when using Claude via api.anthropic.com. CLAUDE_CODE_USE_BEDROCK is set, so this session is using Amazon Bedrock — unset it (or run in a shell without it) to use Remote Control.
1108```1122```
1109 1123
1110第二句解释了什么将会话路由离开 Anthropic API;在 v2.1.219 之前,消息仅为第一句。根据原因,消息命名:1124第二句话解释了是什么让会话绕开了 Anthropic API;在 v2.1.219 之前,消息只有第一句话。根据原因不同,消息会指出:
1111 1125
1112* `CLAUDE_CODE_USE_*` 提供商变量,例如 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock) 的 `CLAUDE_CODE_USE_BEDROCK` 或 [Google Cloud 的 Agent Platform](/docs/zh-CN/google-vertex-ai) 的 `CLAUDE_CODE_USE_VERTEX`1126* 某个 `CLAUDE_CODE_USE_*` 提供商变量,例如用于 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock) 的 `CLAUDE_CODE_USE_BEDROCK` 或用于 [Google Cloud's Agent Platform](/docs/zh-CN/google-vertex-ai) 的 `CLAUDE_CODE_USE_VERTEX`
1113* [`ANTHROPIC_BASE_URL`](/docs/zh-CN/env-vars) 指向 `api.anthropic.com` 以外的主机,例如 [LLM 网关](/docs/zh-CN/llm-gateway) 或代理,即使您使用 claude.ai 登录;在 v2.1.196 之前,自定义基础 URL 不会阻止 Remote Control1127* [`ANTHROPIC_BASE_URL`](/docs/zh-CN/env-vars) 指向 `api.anthropic.com` 以外的主机,例如 [LLM 网关](/docs/zh-CN/llm-gateway)或代理,即使您使用 claude.ai 登录也是如此;在 v2.1.196 之前,自定义 base URL 不会阻止 Remote Control
1114* `ANTHROPIC_UNIX_SOCKET` 已设置,因此会话通过本地套接字而不是 `api.anthropic.com` 发送其请求1128* 设置了 `ANTHROPIC_UNIX_SOCKET`,因此会话通过本地套接字而不是发往 `api.anthropic.com` 来发送请求
1115* 企业 [云网关](/docs/zh-CN/claude-apps-gateway) 通过 `/login` 登录,不支持 Remote Control,没有变量可取消设置1129* 通过 `/login` 完成的企业[云网关](/docs/zh-CN/claude-apps-gateway)登录,它不支持 Remote Control,也没有可以取消设置的变量
1116 1130
1117**应该做什么:**1131**解决方法:**
1118 1132
1119* 取消设置消息命名的变量,例如 `CLAUDE_CODE_USE_BEDROCK` 或 `ANTHROPIC_BASE_URL`,并重新启动会话,或从直接与 Anthropic API 通信的会话启动 Remote Control1133* 取消设置消息中指出的变量(例如 `CLAUDE_CODE_USE_BEDROCK` 或 `ANTHROPIC_BASE_URL`)并重启会话,或从直接与 Anthropic API 通信的会话中启动 Remote Control
1120* 如果变量未在您的 shell 中设置,请检查您的 [设置文件](/docs/zh-CN/settings#where-settings-live) 中的 `env` 键,该键将环境变量应用于每个会话1134* 如果该变量并未在您的 shell 中设置,请检查您[设置文件](/docs/zh-CN/settings#where-settings-live)中的 `env` 键,它会将环境变量应用到每个会话
1121* 对于此和其他 Remote Control 启动消息,请参阅 [Remote Control 故障排除](/docs/zh-CN/remote-control#troubleshooting)1135* 关于此消息及其他 Remote Control 启动消息,请参阅[排除 Remote Control 故障](/docs/zh-CN/remote-control#troubleshooting)
1122 1136
1123<h3 id="remote-control-couldnt-refresh-your-login">1137<h3 id="remote-control-couldnt-refresh-your-login">
1124 Remote Control 无法刷新您的登录1138 Remote Control 无法刷新您的登录
1125</h3>1139</h3>
1126 1140
1127Claude Code 在短期凭证上运行实时 [Remote Control](/docs/zh-CN/remote-control) 连接,它使用您保存的 claude.ai 登录获取和更新这些凭证。当 claude.ai 停止接受该登录或 Claude Code 没有保存的登录时,Claude Code 停止 Remote Control 并需要您再次登录。任一故障都可能在 Claude Code 仍在连接时或稍后在更新凭证时发生。1141Claude Code 使用短期凭据运行实时的 [Remote Control](/docs/zh-CN/remote-control) 连接,这些凭据是它借助您已保存的 claude.ai 登录获取和续期的。当 claude.ai 不再接受该登录,或者 Claude Code 已没有任何已保存的登录时,Claude Code 会停止 Remote Control,需要您重新登录。这两种失败都可能发生在 Claude Code 仍在连接时,也可能发生在之后续期凭据时。
1128 1142
1129当 Claude Code 要求登录服务刷新您保存的登录并且没有得到答复时,它会保持 Remote Control 运行并在连接的当前凭证仍然有效时再次尝试刷新。当 Claude Code 无法到达登录服务、请求超时或服务在不拒绝您的登录的情况下失败时,刷新会得不到答复。如果当该凭证过期时登录服务仍然没有答复,Claude Code 会停止 Remote Control 并报告 `OAuth token refresh failed`。1143当 Claude Code 请求登录服务刷新您已保存的登录却没有得到响应时,它会保持 Remote Control 运行,并在连接的当前凭据仍然有效期间再次尝试刷新。当 Claude Code 无法访问登录服务、请求超时,或服务失败但并未拒绝您的登录时,刷新就会得不到响应。如果在该凭据过期时登录服务仍未响应,Claude Code 会停止 Remote Control 并报告 `OAuth token refresh failed`。
1130 1144
1131当 Claude Code 停止 Remote Control 时,它在警告和以 `Remote Control disconnected` 开头的成绩单行中显示原因。您的本地会话继续运行而没有 Remote Control。本部分涵盖这些行:1145当 Claude Code 停止 Remote Control 时,它会在警告以及一条以 `Remote Control disconnected` 开头的会话记录行中显示原因。您的本地会话会在没有 Remote Control 的情况下继续运行。本节涵盖以下消息行:
1132 1146
1133```text theme={null}1147```text theme={null}
1134Remote Control disconnected — Claude.ai login expired — run /login to restore Remote Control1148Remote Control disconnected — Claude.ai login expired — run /login to restore Remote Control
1140Remote Control disconnected — Signed out of Claude — run /login, then /remote-control1154Remote Control disconnected — Signed out of Claude — run /login, then /remote-control
1141```1155```
1142 1156
1143Claude Code 在消息中间命名原因:1157Claude Code 会在消息中间部分说明原因:
1144 1158
1145* ` Claude.ai login expired` 和 `Claude.ai login was rejected`:claude.ai 不再接受您保存的登录令牌,因为它已过期或被撤销1159* `Claude.ai login expired` 和 `Claude.ai login was rejected`:claude.ai 不再接受您已保存的登录令牌,因为它已过期或被撤销
1146* ` OAuth token unavailable`:当连接的凭证到期需要更新时,Claude Code 没有保存的登录令牌1160* `OAuth token unavailable`:当连接的凭据到期需要续期时,Claude Code 没有已保存的登录令牌
1147* `OAuth token refresh failed`:claude.ai 在 Claude Code 重新连接时拒绝了您保存的登录令牌,刷新令牌没有产生新令牌1161* `OAuth token refresh failed`:Claude Code 重新连接时,claude.ai 拒绝了您已保存的登录令牌,且刷新令牌没有产生新令牌
1148* `JWT refresh failed: no OAuth token`:Claude Code 找不到保存的登录令牌来更新1162* `JWT refresh failed: no OAuth token`:Claude Code 找不到可用于续期的已保存登录令牌
1149* ` Signed out of Claude`:您在此机器上登出,例如在另一个终端中运行 `/logout`,因此 Claude Code 没有保存的登录来更新连接1163* `Signed out of Claude`:您在这台机器上退出了登录,例如在另一个终端中运行了 `/logout`,因此 Claude Code 已没有可用于续期连接的已保存登录
1150 1164
1151**应该做什么:**1165**解决方法:**
1152 1166
1153* 运行 `/login` 再次登录1167* 运行 `/login` 重新登录
1154* 运行 `/remote-control` 重新连接会话。以 `run /login to restore Remote Control` 结尾的消息不需要此步骤:Claude Code 在您登录后自动重新连接。1168* 运行 `/remote-control` 重新连接会话。以 `run /login to restore Remote Control` 结尾的消息不需要此步骤:您登录后 Claude Code 会自动重新连接。
1155 1169
1156在 v2.1.224 之前,`OAuth token refresh failed — run /login to re-authenticate` 读作 `OAuth token refresh failed — re-authenticate, then re-enable Remote Control`,`JWT refresh failed: no OAuth token — run /login` 读作 `no OAuth token available for recovery (code <N>)`。` Claude.ai login expired`、`Claude.ai login was rejected` 和 `OAuth token unavailable` 消息在 v2.1.225 中添加。1170在 v2.1.224 之前,`OAuth token refresh failed — run /login to re-authenticate` 显示为 `OAuth token refresh failed — re-authenticate, then re-enable Remote Control`,`JWT refresh failed: no OAuth token — run /login` 显示为 `no OAuth token available for recovery (code <N>)`。`Claude.ai login expired`、`Claude.ai login was rejected` 和 `OAuth token unavailable` 消息是在 v2.1.225 中添加的。
1157 1171
1158在 v2.1.238 之前,Claude Code 将现在说 `Signed out of Claude` 的情况报告为 `JWT refresh failed: no OAuth token — run /login`,并在一次登录刷新没有得到答复后立即停止 Remote Control,显示 `Claude.ai login expired — run /login to restore Remote Control`。1172在 v2.1.238 之前,Claude Code 将现在显示为 `Signed out of Claude` 的情况报告为 `JWT refresh failed: no OAuth token — run /login`,并且只要有一次登录刷新未得到响应,就会以 `Claude.ai login expired — run /login to restore Remote Control` 停止 Remote Control。
1159 1173
1160<h3 id="remote-control-stopped-because-the-signed-in-account-changed">1174<h3 id="remote-control-stopped-because-the-signed-in-account-changed">
1161 Remote Control 停止,因为登录账户已更改1175 由于登录账户已更改,Remote Control 已停止
1162</h3>1176</h3>
1163 1177
1164Claude Code 在 [Remote Control](/docs/zh-CN/remote-control) 会话期间显示此行,当您在此机器上登录到不同的 claude.ai 账户或组织时。您在 Claude Code 会话外进行了切换,例如在另一个终端中运行 `/login`。1178在 [Remote Control](/docs/zh-CN/remote-control) 会话期间,当您在这台机器上登录到另一个 claude.ai 账户或组织时,Claude Code 会显示这行消息。这种切换是在 Claude Code 会话之外进行的,例如在另一个终端中运行了 `/login`。
1165 1179
1166您在通过 `/login` 登录时启动的 Remote Control 会话属于当时登录的 claude.ai 账户和组织。1180您在通过 `/login` 登录状态下启动的 Remote Control 会话,属于启动时所登录的 claude.ai 账户和组织。
1167 1181
1168```text theme={null}1182```text theme={null}
1169Remote Control disconnected — signed-in claude.ai account or organization changed on this machine — run /remote-control to start a session for the current account, or /login to switch back, then /remote-control1183Remote Control disconnected — signed-in claude.ai account or organization changed on this machine — run /remote-control to start a session for the current account, or /login to switch back, then /remote-control
1170```1184```
1171 1185
1172Claude Code 在 claude.ai 确认账户或组织已更改后立即停止 Remote Control 会话。您的本地会话继续运行而没有 Remote Control。1186一旦 claude.ai 确认账户或组织已更改,Claude Code 就会停止 Remote Control 会话。您的本地会话会在没有 Remote Control 的情况下继续运行。
1173 1187
1174**应该做什么:**1188**解决方法:**
1175 1189
1176* 运行 `/remote-control` 在当前账户或组织下启动新的 Remote Control 会话1190* 运行 `/remote-control`,在当前账户或组织下启动新的 Remote Control 会话
1177* 要切换回去,运行 `/login` 并再次登录到之前的账户或组织。然后运行 `/remote-control`。1191* 如需切换回去,请运行 `/login` 并重新登录之前的账户或组织,然后运行 `/remote-control`。
1178 1192
1179在 v2.1.234 之前,Claude Code 在您在 Claude Code 会话外切换到不同账户或组织时没有注意到。Claude Code 保持 Remote Control 会话连接,直到稍后对 Remote Control 服务器的请求失败,显示 `Remote Control server rejected the request (HTTP 404)`。该故障可能在切换后数小时发生。1193在 v2.1.234 之前,当您在 Claude Code 会话之外切换到其他账户或组织时,Claude Code 不会察觉。Claude Code 会保持 Remote Control 会话连接,直到之后某个发往 Remote Control 服务器的请求以 `Remote Control server rejected the request (HTTP 404)` 失败。该失败可能在切换后数小时才出现。
1180 1194
1181<h3 id="remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts">1195<h3 id="remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts">
1182 Remote Control 停止,因为运行会话的应用登出或切换了账户1196 由于运行会话的应用已退出登录或切换了账户,Remote Control 已停止
1183</h3>1197</h3>
1184 1198
1185当 Claude 桌面应用或 IDE 托管您的会话时,Claude Code 从该应用而不是从 `/login` 获取其登录令牌。当 claude.ai 拒绝该令牌时,Claude Code 要求应用提供新令牌。如果应用回答说它已登出或现在登录到不同的 Claude 账户,Claude Code 结束 [Remote Control](/docs/zh-CN/remote-control) 会话并向应用发送以下行之一:1199当 Claude 桌面应用或 IDE 托管您的会话时,Claude Code 会从该应用而不是从 `/login` 获取登录令牌。当 claude.ai 拒绝该令牌时,Claude Code 会向应用请求新令牌。如果应用回复它已退出登录,或者现在登录的是另一个 Claude 账户,Claude Code 会结束 [Remote Control](/docs/zh-CN/remote-control) 会话,并向应用发送以下消息行之一:
1186 1200
1187```text theme={null}1201```text theme={null}
1188Remote Control stopped — the app running this session is now signed in to a different Claude account1202Remote Control stopped — the app running this session is now signed in to a different Claude account
1189Remote Control stopped — the app running this session is signed out of Claude. Sign in there, then turn Remote Control back on1203Remote Control stopped — the app running this session is signed out of Claude. Sign in there, then turn Remote Control back on
1190```1204```
1191 1205
1192您的本地会话继续运行而没有 Remote Control。1206您的本地会话会在没有 Remote Control 的情况下继续运行。
1193 1207
1194**应该做什么:**1208**解决方法:**
1195 1209
1196* 如果应用已登出,再次登录,然后在应用中重新打开 Remote Control1210* 如果应用已退出登录,请在应用中重新登录,然后在应用中重新打开 Remote Control
1197* 如果应用切换了账户,Claude Code 无法在新账户下继续已结束的会话。在该账户下启动新的 Remote Control 会话。1211* 如果应用切换了账户,Claude Code 无法在新账户下继续已结束的会话。请在该账户下启动新的 Remote Control 会话。
1198 1212
1199在 v2.1.238 之前,Claude Code 在两种情况下都向应用发送了 [Remote Control 无法刷新您的登录](#remote-control-couldnt-refresh-your-login) 下列出的 `run /login` 消息。1213在 v2.1.238 之前,这两种情况下 Claude Code 都会向应用发送[Remote Control 无法刷新您的登录](#remote-control-couldnt-refresh-your-login)中列出的 `run /login` 消息。
1200 1214
1201<h3 id="oauth-token-revoked-or-expired">1215<h3 id="oauth-token-revoked-or-expired">
1202 OAuth 令牌被撤销或过期1216 OAuth 令牌已撤销或已过期
1203</h3>1217</h3>
1204 1218
1205您保存的登录不再有效。被撤销的令牌意味着您在任何地方登出或管理员删除了访问权限;过期的令牌意味着自动刷新在会话中失败。1219您已保存的登录不再有效。令牌被撤销意味着您在所有位置都退出了登录,或者管理员移除了访问权限;令牌过期意味着会话中途的自动刷新失败了。
1206 1220
1207两条消息都报告 API 为 Claude Code 发送的请求返回的拒绝。当保存的登录在失败的刷新后已被清除时,您会看到 [登录过期](#login-expired)。如果您使用 [`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 中的长期令牌进行身份验证,当该令牌过期或被撤销时,您会看到相同的消息。1221这两条消息报告的都是 API 对 Claude Code 所发送请求返回的拒绝。如果已保存的登录在刷新失败后已被清除,您看到的将是[登录已过期](#login-expired)。如果您在 [`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 中使用长期令牌进行身份验证,当该令牌过期或被撤销时,您也会看到同样的消息。
1208 1222
1209```text theme={null}1223```text theme={null}
1210OAuth token revoked · Please run /login1224OAuth token revoked · Please run /login
1211Please run /login · API Error: 401 OAuth token has expired ...1225Please run /login · API Error: 401 OAuth token has expired ...
1212```1226```
1213 1227
1214**应该做什么:**1228在[非交互模式](/docs/zh-CN/headless)(`-p`)和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,消息如下,结构化错误代码为 `authentication_failed`:
1229
1230```text theme={null}
1231Failed to authenticate: OAuth token revoked. Please log in again or contact your administrator.
1232Failed to authenticate. API Error: 401 OAuth token has expired ...
1233```
1215 1234
1216* 运行 `/login` 再次登录1235在 v2.1.287 之前,非交互模式和 Agent SDK 中的撤销消息为 `Your account does not have access to Claude. Please login again or contact your administrator.`
1217* 如果您使用 `CLAUDE_CODE_OAUTH_TOKEN` 环境变量进行身份验证,Claude Code 在请求失败并显示 401 后会继续发送您设置的值,而不是切换到保存的登录的令牌。[`/status`](/docs/zh-CN/commands) 将此凭证显示为读取 `CLAUDE_CODE_OAUTH_TOKEN` 的 `Auth token` 行。使用 [`claude setup-token`](/docs/zh-CN/authentication#generate-a-long-lived-token) 生成新令牌并使用它重新启动,或取消设置变量并运行 `/login`。在 v2.1.225 之前,Claude Code 可以在会话中用保存的登录的短期访问令牌替换变量的值,一旦该令牌过期,会话再次失败并显示 401 错误。1236
1218* 对于跨启动的重复登录提示,请参阅 [故障排除](/docs/zh-CN/troubleshoot-install#not-logged-in-or-token-expired) 中的系统时钟检查和 macOS 凭证存储恢复步骤1237**解决方法:**
1219* 对于其他故障,包括 `403 Forbidden` 和 OAuth 浏览器问题,请参阅 [登录和身份验证](/docs/zh-CN/troubleshoot-install#login-and-authentication)1238
1239* 在 Claude Code 提示符下运行 `/login` 重新登录
1240* 如果您的 `-p` 命令或 Agent SDK 程序使用已保存的登录,请在同一环境中运行 `claude`,完成 `/login`,然后再次运行该命令或程序。对于无法交互式登录的自动化场景,请使用 [`ANTHROPIC_API_KEY`](/docs/zh-CN/env-vars) 进行身份验证,或[使用 `claude setup-token` 生成长期令牌](/docs/zh-CN/authentication#generate-a-long-lived-token)。
1241* 如果您使用 `CLAUDE_CODE_OAUTH_TOKEN` 环境变量进行身份验证,在请求以 401 失败后,Claude Code 会继续发送您设置的值,而不会切换到已存储登录的令牌。[`/status`](/docs/zh-CN/commands) 会将此凭据显示为一个 `Auth token` 行,内容为 `CLAUDE_CODE_OAUTH_TOKEN`。请使用 [`claude setup-token`](/docs/zh-CN/authentication#generate-a-long-lived-token) 生成新令牌并用它重启,或取消设置该变量并运行 `/login`。在 v2.1.225 之前,Claude Code 可能会在会话中途用已存储登录的短期访问令牌替换该变量的值,一旦该令牌过期,会话就会再次因 401 错误而失败。
1242* 如果每次启动都反复提示您登录,请参阅[故障排除](/docs/zh-CN/troubleshoot-install#not-logged-in-or-token-expired)中的系统时钟检查和 macOS 凭据存储恢复步骤
1243* 对于其他失败,包括 `403 Forbidden` 和 OAuth 浏览器问题,请参阅[登录和身份验证](/docs/zh-CN/troubleshoot-install#login-and-authentication)
1220 1244
1221<h3 id="api-error-401-invalid-authentication-credentials">1245<h3 id="api-error-401-invalid-authentication-credentials">
1222 API 错误:401 无效的身份验证凭证1246 API Error: 401 Invalid authentication credentials
1223</h3>1247</h3>
1224 1248
1225API 识别了您凭证的格式,但拒绝了其背后的账户或组织。当凭证最近被撤销、组织被禁用或删除了您的访问权限或账户本身被停用时,Anthropic 返回此消息,因此过期的令牌不是原因。凭证可以是您保存的登录或批准的 `ANTHROPIC_API_KEY`,修复方式不同,因此首先运行 `/status` 查看哪个处于活跃状态。1249API 识别了您凭据的格式,但拒绝了其背后的账户或组织。当凭据最近被撤销、组织被停用或移除了您的访问权限,或账户本身被停用时,Anthropic 会返回此消息,因此原因并不是令牌过期。该凭据可能是您已保存的登录,也可能是已批准的 `ANTHROPIC_API_KEY`,两者的修复方法不同,因此请先运行 `/status` 查看当前生效的是哪一个。
1226 1250
1227```text theme={null}1251```text theme={null}
1228Please run /login · API Error: 401 Invalid authentication credentials1252Please run /login · API Error: 401 Invalid authentication credentials
1229```1253```
1230 1254
1231**应该做什么:**1255**解决方法:**
1232 1256
1233* 如果 `/status` 显示未标记为未使用的 `API key` 行,则批准的 [`ANTHROPIC_API_KEY`](/docs/zh-CN/authentication#authentication-precedence) 是活跃凭证并优先于您的登录,因此 `/login` 不会替换它。在 Claude Console 中轮换密钥,或通过运行 `unset ANTHROPIC_API_KEY` 回退到您的订阅,或在 PowerShell 中运行 `Remove-Item Env:ANTHROPIC_API_KEY`。1257* 如果 `/status` 显示一个未标记为未使用的 `API key` 行,说明已批准的 [`ANTHROPIC_API_KEY`](/docs/zh-CN/authentication#authentication-precedence) 是当前生效的凭据,并且优先于您的登录,因此 `/login` 不会替换它。请在 Claude Console 中轮换该密钥,或通过运行 `unset ANTHROPIC_API_KEY`(在 PowerShell 中为 `Remove-Item Env:ANTHROPIC_API_KEY`)回退到您的订阅。
1234* 如果 `/status` 仅显示您的登录,运行 `/login` 一次。如果凭证被撤销,新登录会替换它。1258* 如果 `/status` 只显示您的登录,请运行一次 `/login`。如果凭据已被撤销,新的登录会替换它。
1235* 如果相同的消息对相同的登录账户返回,则该账户或组织不再活跃。检查 `/status` 报告的账户和组织,并要求您的组织管理员恢复访问。1259* 如果同一登录账户再次出现相同消息,说明该账户或组织已不再活跃。请检查 `/status` 报告的账户和组织,并请您的组织管理员恢复访问权限。
1236* 如果 [`ANTHROPIC_BASE_URL`](/docs/zh-CN/env-vars) 指向 [LLM 网关](/docs/zh-CN/llm-gateway),`401` 之后的文本是您网关的消息而不是 Anthropic 的,`/login` 不会改变它。改为修复您的网关期望的凭证。1260* 如果 [`ANTHROPIC_BASE_URL`](/docs/zh-CN/env-vars) 指向 [LLM 网关](/docs/zh-CN/llm-gateway),`401` 之后的文本是您网关的消息而不是 Anthropic 的消息,`/login` 不会改变它。请改为修正网关所需的凭据。
1237 1261
1238<h3 id="login-expired">1262<h3 id="login-expired">
1239 登录过期1263 登录已过期
1240</h3>1264</h3>
1241 1265
1242Claude Code 尝试更新您保存的 claude.ai 登录,OAuth 服务拒绝了存储的刷新令牌,因此 Claude Code 清除了保存的凭证。之后,每个模型请求在到达 API 之前都会在本地停止,显示此消息,因为只有 `/login` 可以创建新凭证。1266Claude Code 尝试续期您已保存的 claude.ai 登录,但 OAuth 服务拒绝了已存储的刷新令牌,因此 Claude Code 清除了已保存的凭据。此后,每个模型请求都会在到达 API 之前于本地以此消息停止,因为只有 `/login` 才能创建新凭据。
1243 1267
1244在 v2.1.206 之前,Claude Code 无论如何都会发送模型请求,使用环境中剩余的任何凭证,每个模型都会失败,显示 [所选模型有问题](#theres-an-issue-with-the-selected-model) 或 401,而不是登录提示。1268在 v2.1.206 之前,Claude Code 仍会使用环境中剩余的任何凭据发送模型请求,然后每个模型都会以[所选模型存在问题](#theres-an-issue-with-the-selected-model)或 401 失败,而不是提示您登录。
1245 1269
1246```text theme={null}1270```text theme={null}
1247Login expired · Please run /login1271Login expired · Please run /login
1248```1272```
1249 1273
1250在 [非交互式模式](/docs/zh-CN/headless) (`-p`) 和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,消息如下所示,结构化错误代码为 `authentication_failed`:1274在[非交互模式](/docs/zh-CN/headless)(`-p`)和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,消息如下,结构化错误代码为 `authentication_failed`:
1251 1275
1252```text theme={null}1276```text theme={null}
1253Failed to authenticate: OAuth session expired and could not be refreshed1277Failed to authenticate: OAuth session expired and could not be refreshed
1254```1278```
1255 1279
1256这与 [OAuth 令牌被撤销或过期](#oauth-token-revoked-or-expired) 的状态不同。这些消息报告 API 返回的拒绝。Claude Code 本身为已失败更新的登录生成 `Login expired`,因此它不发送请求。当更新失败是因为账户本身被暂停而不是登录过时时,Claude Code 改为显示 [您的账户被冻结](#your-account-is-on-hold)。1280这与 [OAuth 令牌已撤销或已过期](#oauth-token-revoked-or-expired)并非同一状态。那些消息报告的是 API 返回的拒绝。而 `Login expired` 是 Claude Code 针对已续期失败的登录自行生成的,因此它不会发送任何请求。当续期失败是因为账户本身被暂停而不是登录过时,Claude Code 会改为显示[您的账户已被暂停](#your-account-is-on-hold)。
1257 1281
1258使用 API 密钥、[`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 或第三方提供商进行身份验证的会话不使用保存的登录,永远不会看到此消息。1282使用 API 密钥、[`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 或第三方提供商进行身份验证的会话不使用已保存的登录,永远不会看到此消息。
1259 1283
1260您可以在请求失败之前检查此状态:[`/status`](/docs/zh-CN/commands) 显示读取 `Expired — log in again` 的 `Login` 行,加上它为过期登录保存的组织和电子邮件。该行仅在保存的登录是您的活跃凭证且无法再刷新时出现。以其他方式进行身份验证的会话不显示该行,即使过期的登录仍然保存。在 v2.1.210 之前,`/status` 在此状态下没有指示登录曾经存在过,因为清除的凭证使其无法报告。1284您可以在请求失败之前检查是否处于此状态:[`/status`](/docs/zh-CN/commands) 会显示一个 `Login` 行,内容为 `Expired — log in again`,以及它为该过期登录保存的组织和电子邮件。只有当已保存的登录是您当前生效的凭据且无法再刷新时,才会显示该行。以其他方式进行身份验证的会话不会显示该行,即使仍保存着已过期的登录。在 v2.1.210 之前,`/status` 在此状态下不会提供任何曾存在登录的迹象,因为凭据已被清除,没有可报告的内容。
1261 1285
1262**应该做什么:**1286**解决方法:**
1263 1287
1264* 运行 `/login` 再次登录。在不登录的情况下重试会在每个请求上显示相同的消息。1288* 运行 `/login` 重新登录。不登录而直接重试,每个请求都会显示相同的消息。
1265* 在非交互式模式中,在同一环境中运行 `claude`,完成 `/login`,然后重新运行您的命令。对于无法交互式登录的自动化,使用 `ANTHROPIC_API_KEY` 进行身份验证或 [使用 `claude setup-token` 生成长期令牌](/docs/zh-CN/authentication#generate-a-long-lived-token)。1289* 如果您在另一个 Claude Code 窗口中使用 claude.ai 账户登录,请参阅[未登录](#not-logged-in),了解此会话何时会自动开始使用该登录。
1266* 如果登录持续失败,请参阅 [登录和身份验证](/docs/zh-CN/troubleshoot-install#login-and-authentication)1290* 在非交互模式下,请在同一环境中运行 `claude`,完成 `/login`,然后重新运行您的命令。对于无法交互式登录的自动化场景,请使用 `ANTHROPIC_API_KEY` 进行身份验证,或[使用 `claude setup-token` 生成长期令牌](/docs/zh-CN/authentication#generate-a-long-lived-token)。
1291* 如果登录一直失败,请参阅[登录和身份验证](/docs/zh-CN/troubleshoot-install#login-and-authentication)
1267 1292
1268<h3 id="could-not-refresh-your-login">1293<h3 id="could-not-refresh-your-login">
1269 无法刷新您的登录,因为另一个 Claude Code 进程正在刷新它1294 由于另一个 Claude Code 进程正在刷新您的登录,无法刷新
1270</h3>1295</h3>
1271 1296
1272此消息不意味着您的登录被拒绝。您保存的 claude.ai 登录已过期,需要更新。另一个 Claude Code 进程在同一机器上持有共享刷新锁,或退出并留下它,刷新在此会话等待时没有进展。Claude Code 在发送前停止请求:1297此消息并不表示您的登录被拒绝。您已保存的 claude.ai 登录已过期,需要续期。同一台机器上的另一个 Claude Code 进程持有共享的刷新锁,或者该进程已退出但遗留了该锁,在此会话等待期间刷新没有任何进展。Claude Code 会在发送前停止请求:
1273 1298
1274```text theme={null}1299```text theme={null}
1275Could not refresh your login because another Claude Code process is refreshing it (or exited mid-refresh) · Try again in a minute; if it keeps happening, close other Claude Code windows or sign in again with /login1300Could not refresh your login because another Claude Code process is refreshing it (or exited mid-refresh) · Try again in a minute; if it keeps happening, close other Claude Code windows or sign in again with /login
1276```1301```
1277 1302
1278在 [非交互式模式](/docs/zh-CN/headless) (`-p`) 和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,消息如下所示,结构化错误代码为 `server_error`:1303在[非交互模式](/docs/zh-CN/headless)(`-p`)和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,消息如下,结构化错误代码为 `server_error`:
1279 1304
1280```text theme={null}1305```text theme={null}
1281Failed to refresh OAuth token: another Claude Code process is refreshing it or exited mid-refresh. This is usually transient; retry in a minute, and if it persists close other Claude Code processes or sign in again1306Failed to refresh OAuth token: another Claude Code process is refreshing it or exited mid-refresh. This is usually transient; retry in a minute, and if it persists close other Claude Code processes or sign in again
1282```1307```
1283 1308
1284使用 API 密钥、[`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 或第三方提供商进行身份验证的会话不使用保存的登录,永远不会看到此消息。1309使用 API 密钥、[`CLAUDE_CODE_OAUTH_TOKEN`](/docs/zh-CN/env-vars) 或第三方提供商进行身份验证的会话不使用已保存的登录,永远不会看到此消息。
1285 1310
1286**应该做什么:**1311**解决方法:**
1287 1312
1288* 一分钟后重试。如果另一个进程首先完成刷新,此会话使用更新的登录。1313* 一分钟后重试。如果另一个进程先完成了刷新,此会话会使用续期后的登录。
1289* 如果消息持续返回,关闭其他 Claude Code 窗口和进程,然后重试。1314* 如果消息反复出现,请关闭其他 Claude Code 窗口和进程,然后重试。
1290* 如果在没有其他 Claude Code 进程运行的情况下返回,运行 `/login`。再次登录不会等待刷新锁。1315* 如果在没有其他 Claude Code 进程运行的情况下仍出现该消息,请运行 `/login`。重新登录不会等待刷新锁。
1291 1316
1292<h3 id="couldnt-save-your-login">1317<h3 id="couldnt-save-your-login">
1293 无法保存您的登录1318 无法保存您的登录
1294</h3>1319</h3>
1295 1320
1296您使用 claude.ai 登录,但 Claude Code 无法将登录保存到其凭证存储,因此登录未完成。在 macOS 上,当登录钥匙链锁定时(例如在睡眠或空闲时),在 Claude Code 已在同一会话中读取或保存凭证之后,可能会发生这种情况。1321您已使用 claude.ai 登录,但 Claude Code 无法将登录保存到其凭据存储中,因此登录未完成。在 macOS 上,如果 Claude Code 在同一会话中已经读取或保存过登录钥匙串中的凭据,之后钥匙串被锁定(例如在睡眠或空闲时),就可能发生这种情况。
1297 1322
1298```text theme={null}1323```text theme={null}
1299Couldn't save your login. If your Mac's keychain is locked, unlock it and log in again.1324Couldn't save your login. If your Mac's keychain is locked, unlock it and log in again.
1300Couldn't save your login. Try logging in again.1325Couldn't save your login. Try logging in again.
1301```1326```
1302 1327
1303第一种形式出现在 macOS 上,第二种形式出现在其他地方。临时凭证存储故障(例如超时或不可读的存储)会产生相同的消息。1328第一种形式出现在 macOS 上,第二种形式出现在其他所有平台上。暂时性的凭据存储失败(例如超时或存储无法读取)也会产生同样的消息。
1304 1329
1305**应该做什么:**1330**解决方法:**
1306 1331
1307* 在 macOS 上,解锁登录钥匙链,然后再次运行 `/login`1332* 在 macOS 上,解锁登录钥匙串,然后再次运行 `/login`
1308* 在其他平台上,再次运行 `/login`1333* 在其他平台上,再次运行 `/login`
1309* 如果登录仍然不保存,请参阅 [未登录或令牌过期](/docs/zh-CN/troubleshoot-install#not-logged-in-or-token-expired) 了解钥匙链解锁命令和其他凭证存储恢复步骤1334* 如果登录仍然无法保存,请参阅[未登录或令牌已过期](/docs/zh-CN/troubleshoot-install#not-logged-in-or-token-expired),了解钥匙串解锁命令和其他凭据存储恢复步骤
1310 1335
1311<h3 id="failed-to-start-oauth-callback-server">1336<h3 id="failed-to-start-oauth-callback-server">
1312 Failed to start OAuth callback server1337 无法启动 OAuth 回调服务器
1313</h3>1338</h3>
1314 1339
1315当 `/login`、`claude auth login` 或 `claude setup-token` 通过浏览器登录您时,Claude Code 在 `127.0.0.1` 上打开一个监听端口,以便您的浏览器可以将登录结果返回给它。此消息意味着 Claude Code 无法打开该端口,登录在浏览器窗口或登录 URL 出现之前停止:1340当 `/login`、`claude auth login` 或 `claude setup-token` 通过浏览器为您登录时,Claude Code 会在 `127.0.0.1` 上打开一个监听端口,以便浏览器将登录结果返回给它。此消息表示 Claude Code 无法打开该端口,登录会在浏览器窗口或登录 URL 出现之前停止:
1316 1341
1317```text theme={null}1342```text theme={null}
1318Failed to start OAuth callback server: Failed to start server. Is port 0 in use?1343Failed to start OAuth callback server: Failed to start server. Is port 0 in use?
1319```1344```
1320 1345
1321如果您的消息以 `Is port 0 in use?` 结尾,尝试在 IPv4 环回地址 `127.0.0.1` 上监听的尝试完全失败。因为故障发生在登录 URL 存在之前,`Paste code here if prompted` 流不可用作解决方法。1346如果您的消息以 `Is port 0 in use?` 结尾,说明在 IPv4 回环地址 `127.0.0.1` 上监听的尝试直接失败了。由于失败发生在登录 URL 生成之前,`Paste code here if prompted` 流程无法作为变通方案使用。
1322 1347
1323**应该做什么:**1348**解决方法:**
1324 1349
1325* 要立即登录而不需要本地监听器:如果您使用 claude.ai 订阅,在登录有效的机器上运行 [`claude setup-token`](/docs/zh-CN/authentication#generate-a-long-lived-token) 并将其打印的令牌设置为此机器上的 `CLAUDE_CODE_OAUTH_TOKEN`。否则将 `ANTHROPIC_API_KEY` 设置为来自 [Claude Console](https://platform.claude.com/settings/keys) 的密钥。[身份验证优先级](/docs/zh-CN/authentication#authentication-precedence) 解释了 Claude Code 在存在多个凭证时如何选择。1350* 如需不使用本地监听器立即登录:如果您使用 claude.ai 订阅,请在可以正常登录的机器上运行 [`claude setup-token`](/docs/zh-CN/authentication#generate-a-long-lived-token),并在这台机器上将它输出的令牌设置为 `CLAUDE_CODE_OAUTH_TOKEN`。否则,请将 `ANTHROPIC_API_KEY` 设置为来自 [Claude Console](https://platform.claude.com/settings/keys) 的密钥。[身份验证优先级](/docs/zh-CN/authentication#authentication-precedence)解释了 Claude Code 如何在多个凭据之间进行选择。
1326* 要在此机器上改用浏览器登录,Claude Code 必须能够在 `127.0.0.1` 上监听。如果它在沙箱内运行,检查沙箱的策略是否允许在本地端口上监听,然后再次运行 `/login`。如果它应该能够但仍然失败,运行 `/feedback` 以便报告包含您的环境详细信息。1351* 如果要改为在这台机器上使用浏览器登录,Claude Code 必须能够在 `127.0.0.1` 上监听。如果它在沙箱中运行,请检查沙箱策略是否允许监听本地端口,然后再次运行 `/login`。如果它本应能够监听却仍然失败,请运行 `/feedback`,以便报告中包含您的环境详细信息。
1327 1352
1328<h3 id="claude-login-not-accepted">1353<h3 id="claude-login-not-accepted">
1329 Claude login not accepted1354 Claude 登录未被接受
1330</h3>1355</h3>
1331 1356
1332您尝试启动 [云会话](/docs/zh-CN/claude-code-on-the-web),服务器拒绝使用 401 创建它:它不接受此机器发送的 Claude 登录,通常是因为登录过期或被撤销。1357您尝试启动一个[云端会话](/docs/zh-CN/claude-code-on-the-web),服务器以 401 拒绝创建它:服务器不接受这台机器发送的 Claude 登录,通常是因为该登录已过期或被撤销。
1333 1358
1334当服务器给出自己的原因时,行的第一部分是该原因。否则该行读作:1359如果服务器给出了原因,该行的第一部分就是服务器自己的原因。否则,该行显示为:
1335 1360
1336```text theme={null}1361```text theme={null}
1337Claude login not accepted · Run /login, then try again1362Claude login not accepted · Run /login, then try again
1338```1363```
1339 1364
1340**应该做什么:**1365**解决方法:**
1341 1366
1342* 运行 `/login`,完成登录,然后再次启动会话1367* 运行 `/login`,完成登录,然后再次启动会话
1343 1368
1344<h3 id="artifacts-need-a-claude-ai-login">1369<h3 id="artifacts-need-a-claude-ai-login">
1345 工件需要 claude.ai 登录1370 Artifact 需要 claude.ai 登录
1346</h3>1371</h3>
1347 1372
1348Claude Code 拒绝了 [工件](/docs/zh-CN/artifacts) 发布或读取,因为会话没有可用于工件的 claude.ai 登录。1373Claude Code 拒绝了 [Artifact](/docs/zh-CN/artifacts) 的发布或读取,因为该会话没有可用于 Artifact 的 claude.ai 登录。
1349 1374
1350消息的每种形式都以相同的词开头,然后是取决于您的会话如何进行身份验证的补救措施。没有竞争凭证时,它读作:1375该消息的每种形式都以相同的文字开头,后面跟着的补救措施取决于您的会话如何进行身份验证。没有竞争凭据时,消息显示为:
1351 1376
1352```text theme={null}1377```text theme={null}
1353Artifacts need a claude.ai login. Run /login and select "Claude account with subscription", then retry — the "Anthropic Console account" option does not provide claude.ai credentials.1378Artifacts need a claude.ai login. Run /login and select "Claude account with subscription", then retry — the "Anthropic Console account" option does not provide claude.ai credentials.
1354```1379```
1355 1380
1356**应该做什么:**1381**解决方法:**
1357 1382
1358* 运行 `/login` 并选择 **Claude account with subscription**。**Anthropic Console account** 选项不提供 claude.ai 凭证。1383* 运行 `/login` 并选择 **Claude account with subscription**。**Anthropic Console account** 选项不提供 claude.ai 凭据。
1359* 当消息命名优先的凭证(如 `ANTHROPIC_API_KEY`、`apiKeyHelper` 设置或之前 `/login` 保存的 Console 密钥)时,按消息说的方式删除它,然后运行 `/login`1384* 当消息指出某个优先级更高的凭据时,例如 `ANTHROPIC_API_KEY`、`apiKeyHelper` 设置或之前的 `/login` 保存的 Console 密钥,请按消息所述将其移除,然后运行 `/login`
1360* 当消息说此远程会话通过启动它的机器进行身份验证时,在该机器上登录到 claude.ai,然后重新连接会话1385* 当消息说明此远程会话通过启动它的机器进行身份验证时,请在那台机器上登录 claude.ai,然后重新连接会话
1361* 当消息说凭证由会话的主机环境注入时,您无法在该会话中更改它;启动登录到 claude.ai 的会话1386* 当消息说明凭据由会话的宿主环境注入时,您无法在该会话中更改它;请启动一个已登录 claude.ai 的会话
1362* 请参阅 [可用性](/docs/zh-CN/artifacts#availability) 了解工件具有的其他要求,例如计划、模型提供商和组织策略1387* 请参阅[可用性](/docs/zh-CN/artifacts#availability),了解 Artifact 的其他要求,例如套餐、模型提供商和组织策略
1363 1388
1364<h3 id="administrator-policy-requires-a-cloud-gateway-sign-in">1389<h3 id="administrator-policy-requires-a-cloud-gateway-sign-in">
1365 管理员策略需要 Cloud gateway 登录1390 管理员策略要求使用云网关登录
1366</h3>1391</h3>
1367 1392
1368管理员在此机器上的 [托管设置](/docs/zh-CN/managed-settings) 将 [`forceLoginMethod`](/docs/zh-CN/settings-reference#forceloginmethod) 设置为 `"gateway"` 或设置 [`forceLoginGatewayUrl`](/docs/zh-CN/settings-reference#forcelogingatewayurl)。除非您通过 `CLAUDE_CODE_USE_BEDROCK` 等变量选择云提供商,Claude Code 仅接受 [Claude apps gateway](/docs/zh-CN/claude-apps-gateway) 登录。您会看到两条消息之一:1393这台机器上管理员的[托管设置](/docs/zh-CN/managed-settings)将 [`forceLoginMethod`](/docs/zh-CN/settings-reference#forceloginmethod) 设置为 `"gateway"`,或设置了 [`forceLoginGatewayUrl`](/docs/zh-CN/settings-reference#forcelogingatewayurl)。除非您通过 `CLAUDE_CODE_USE_BEDROCK` 等变量选择了云服务提供商,否则 Claude Code 只接受 [Claude apps gateway](/docs/zh-CN/claude-apps-gateway) 登录。您会看到以下两种消息之一:
1369 1394
1370```text theme={null}1395```text theme={null}
1371Not signed in to the Cloud gateway — run /login.1396Not signed in to the Cloud gateway — run /login.
1372```1397```
1373 1398
1374当会话没有网关登录时,模型请求失败,显示此消息,例如因为您自策略到达机器后未运行 `/login`。1399当会话没有网关登录时,模型请求会以此消息失败,例如因为在该策略下发到这台机器后您还没有运行过 `/login`。
1400
1401如果这台机器上还存在 Anthropic 签发的凭据,并且托管设置设置了 `forceLoginMethod` 或 `forceLoginOrgUUID`,Claude Code 则会在启动时退出。该凭据可能是 `ANTHROPIC_API_KEY` 或 `ANTHROPIC_AUTH_TOKEN` 变量、`apiKeyHelper` 设置,或之前的 Claude Console 登录保存的 API 密钥。
1375 1402
1376如果机器还持有 Anthropic 颁发的凭证且托管设置设置了 `forceLoginMethod` 或 `forceLoginOrgUUID`,Claude Code 在启动时改为以此消息退出:1403启动消息会指出会话所配置的凭据、它的设置位置以及移除它的步骤。例如,当您在 shell 中设置了 `ANTHROPIC_API_KEY` 变量时,消息显示为:
1377 1404
1378```text theme={null}1405```text theme={null}
1379Administrator policy requires a Cloud gateway sign-in on this machine; the1406Administrator policy requires a Cloud gateway sign-in on this machine, but this session is configured with an API key from ANTHROPIC_API_KEY, which a gateway machine does not accept.
1380Anthropic-issued credential configured here (ANTHROPIC_API_KEY,1407
1381ANTHROPIC_AUTH_TOKEN, or apiKeyHelper) is not used.1408To continue: unset ANTHROPIC_API_KEY (or run in a shell without it), then run claude and sign in with /login.
1382```1409```
1383 1410
1384**应该做什么:**1411**解决方法:**
1385 1412
1386* 运行 `/login` 并在 **Cloud gateway** 屏幕上完成登录1413* 对于 `Not signed in to the Cloud gateway`,请运行 `/login` 并在 **Cloud gateway** 界面上完成登录
1387* 对于启动消息,删除您配置的 `ANTHROPIC_API_KEY`、`ANTHROPIC_AUTH_TOKEN` 或 `apiKeyHelper` 设置。要删除保存的 Console API 密钥,运行 `claude auth logout`,这也会删除保存的 claude.ai 登录。如果您使用 `CLAUDE_CODE_USE_*` 选择云提供商,会话然后以无登录启动。否则启动 `claude` 并运行 `/login`1414* 对于启动消息,请按照消息末尾的步骤移除该凭据
1388* 如果您认为机器不应该需要网关,请要求管理该机器的管理员从其托管设置中删除 `forceLoginMethod` 和 `forceLoginGatewayUrl`1415* 如果您认为这台机器不应要求使用网关,请让管理该机器的管理员从其托管设置中移除 `forceLoginMethod` 和 `forceLoginGatewayUrl`
1389 1416
1390在 v2.1.265 上,回归也在某些 LLM 网关和代理配置中显示第一条消息,这些配置使用 API 密钥、`apiKeyHelper` 或自定义标头进行身份验证,即使机器上没有管理员要求。更新到 v2.1.266 或更高版本。您不需要更改您的配置。1417在 v2.1.284 之前,启动消息会列出可能的凭据,而不是指出已配置的那一个。它以 `Administrator policy requires a Cloud gateway sign-in on this machine; the Anthropic-issued credential configured here (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, or apiKeyHelper) is not used.` 开头。如果您看到的是这种措辞且无法判断要移除哪个凭据,请更新到 v2.1.284 或更高版本,然后再次启动 `claude`。
1391 1418
1392在 v2.1.261 之前,在将 `forceLoginMethod` 设置为 `"gateway"` 的机器上,Claude Code 使用剩余的保存登录而不是失败模型请求,并使用 `This machine's managed settings require a first-party login` 而不是启动消息报告配置的环境凭证。在 v2.1.265 之前,其托管设置仅设置 `forceLoginGatewayUrl` 的机器不需要网关登录,Claude Code 在那里使用剩余凭证。1419在 v2.1.265 上,一个回归问题还会在某些使用 API 密钥、`apiKeyHelper` 或自定义标头进行身份验证的 LLM 网关和代理配置中显示第一条消息,即使机器上没有管理员要求也是如此。请更新到 v2.1.266 或更高版本。您无需更改配置。
1420
1421在 v2.1.261 之前,在将 `forceLoginMethod` 设置为 `"gateway"` 的机器上,Claude Code 会使用遗留的已保存登录,而不是让模型请求失败,并且会以 `This machine's managed settings require a first-party login` 报告已配置的环境凭据,而不是显示启动消息。
1393 1422
1394<h3 id="your-account-is-on-hold">1423<h3 id="your-account-is-on-hold">
1395 您的账户被冻结1424 您的账户已被暂停
1396</h3>1425</h3>
1397 1426
1398您的 Claude 账户背后的登录已被暂停。Claude Code 在尝试更新您保存的登录并了解冻结时显示第一条消息,在您在浏览器中完成的登录报告时显示第二条消息:1427您登录所用的 Claude 账户已被暂停。当 Claude Code 尝试续期您已保存的登录并获知暂停时,会显示第一条消息;当您在浏览器中完成的登录报告暂停时,会显示第二条消息:
1399 1428
1400```text theme={null}1429```text theme={null}
1401Your account is on hold and can't use Claude Code. View details or appeal: https://claude.ai/restricted1430Your account is on hold and can't use Claude Code. View details or appeal: https://claude.ai/restricted
1402Your account is on hold and can't sign in to Claude Code. View details or appeal: https://claude.ai/restricted1431Your account is on hold and can't sign in to Claude Code. View details or appeal: https://claude.ai/restricted
1403```1432```
1404 1433
1405使用同一账户再次登录不会清除消息,因为冻结是在账户上而不是登录上。在 [非交互式模式](/docs/zh-CN/headless) (`-p`) 和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,结构化错误代码为 `account_on_hold`。在 v2.1.235 之前,Claude Code 将被冻结的账户报告为 [登录过期 · 请运行 /login](#login-expired),其恢复步骤无法清除冻结。1434使用同一账户重新登录不会清除该消息,因为暂停针对的是账户而不是登录。在[非交互模式](/docs/zh-CN/headless)(`-p`)和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,结构化错误代码为 `account_on_hold`。在 v2.1.235 之前,Claude Code 会将被暂停的账户报告为 [Login expired · Please run /login](#login-expired),而其恢复步骤无法解除暂停。
1406 1435
1407**应该做什么:**1436**解决方法:**
1408 1437
1409* 打开消息中的链接以查看冻结的详细信息或对其提出上诉1438* 打开消息中的链接,查看暂停的详细信息或提出申诉
1410* 如果您有另一个 Claude 账户或不受冻结影响的 API 密钥,您可以在冻结解决期间继续工作:使用该账户运行 `/login`,或使用 `ANTHROPIC_API_KEY` 设置密钥1439* 如果您有不受暂停影响的其他 Claude 账户或 API 密钥,可以在暂停解决期间继续工作:使用该账户运行 `/login`,或通过 `ANTHROPIC_API_KEY` 设置该密钥
1411 1440
1412<h3 id="anthropic-profile-login-expired">1441<h3 id="anthropic-profile-login-expired">
1413 Anthropic 配置文件登录过期1442 Anthropic 配置文件登录已过期
1414</h3>1443</h3>
1415 1444
1416Claude Code 通过 Anthropic 凭证配置文件进行身份验证,其保存的登录凭证已过期,且配置文件不包含 Claude Code 可用于更新它的刷新凭证。Claude Code 在本地停止每个请求而不重试,因为重试会读取相同的过期凭证。1445Claude Code 正在通过一个 Anthropic 凭据配置文件进行身份验证,该配置文件中已保存的登录凭据已过期,并且配置文件中没有 Claude Code 可用于续期的刷新凭据。Claude Code 会在本地停止每个请求且不重试,因为重试只会读取同一个已过期的凭据。
1417 1446
1418```text theme={null}1447```text theme={null}
1419Anthropic profile login expired · Re-authenticate your Anthropic profile1448Anthropic profile login expired · Re-authenticate your Anthropic profile
1420Anthropic profile login expired · Run /login to use your claude.ai account instead, or re-authenticate the profile1449Anthropic profile login expired · Run /login to use your claude.ai account instead, or re-authenticate the profile
1421```1450```
1422 1451
1423这仅在活跃凭证来自 Anthropic 凭证配置文件时出现,您使用 `ANTHROPIC_PROFILE` 环境变量选择该文件,Claude Code 从您的 Anthropic 配置目录中发现为活跃配置文件,或 Claude Code 在您 [不使用 API 密钥登录](/docs/zh-CN/authentication#sign-in-without-an-api-key) 时写入。使用 `/login` 的 claude.ai 选项、API 密钥、持有者令牌(如 `ANTHROPIC_AUTH_TOKEN`)或第三方提供商进行身份验证的会话永远不会看到此消息。1452只有当生效的凭据来自 Anthropic 凭据配置文件时才会出现此消息,该配置文件可以是您通过 `ANTHROPIC_PROFILE` 环境变量选择的、Claude Code 在您的 Anthropic 配置目录中发现为活跃配置文件的,或是您[在没有 API 密钥的情况下登录](/docs/zh-CN/authentication#sign-in-without-an-api-key)时 Claude Code 写入的。使用 API 密钥、bearer 令牌(例如 `ANTHROPIC_AUTH_TOKEN`)或第三方提供商进行身份验证的会话永远不会看到此消息。
1424 1453
1425在 [提供无密钥登录](/docs/zh-CN/authentication#sign-in-without-an-api-key) 的机器上,运行 `/login`,选择 Anthropic Console 账户,并再次登录以更新无密钥 Console 登录或 Claude Platform CLI 的 `ant auth login` 写入的配置文件。Claude Code 替换该配置文件中的过期凭证。对于联合配置文件或另一个工具创建的配置文件,`/login` 不会更新凭证。您看到的形式取决于您是否显式选择了配置文件或 Claude Code 发现了它:1454在[提供无密钥登录](/docs/zh-CN/authentication#sign-in-without-an-api-key)的机器上,运行 `/login`,选择 Anthropic Console 账户并重新登录,即可续期由无密钥 Console 登录或 Claude Platform CLI 的 `ant auth login` 写入的配置文件。Claude Code 会替换该配置文件中已过期的凭据。对于联合身份配置文件或由其他工具创建的配置文件,`/login` 不会续期凭据。您看到哪种形式,取决于配置文件是您选择的还是 Claude Code 发现的:
1426 1455
1427* 当您显式设置 `ANTHROPIC_PROFILE` 时,消息以 `Re-authenticate your Anthropic profile` 结尾。1456* 当您显式设置了 `ANTHROPIC_PROFILE` 时,消息以 `Re-authenticate your Anthropic profile` 结尾。
1428* 当 Claude Code 从您的配置目录发现配置文件时,消息提供 `/login`,因为 Claude Code 给予工作的 `/login` 优先于发现的配置文件,然后改为使用您的 claude.ai 或 Console 账户进行身份验证。在 v2.1.234 之前,Claude Code 在这种情况下也显示 `Re-authenticate your Anthropic profile` 形式。1457* 当 Claude Code 从您的配置目录中发现该配置文件时,消息会提供 `/login` 选项,因为 Claude Code 让可用的 `/login` 优先于所发现的配置文件,然后改用您的 claude.ai 或 Console 账户进行身份验证。在 v2.1.234 之前,这种情况下 Claude Code 也会显示 `Re-authenticate your Anthropic profile` 形式。
1429 1458
1430**应该做什么:**1459**解决方法:**
1431 1460
1432* 再次登录到配置文件,然后重试:在 [提供无密钥登录](/docs/zh-CN/authentication#sign-in-without-an-api-key) 的机器上,运行 `/login` 并为无密钥 Console 登录或 Claude Platform CLI 的 `ant auth login` 写入的配置文件选择 Anthropic Console 账户;对于其他配置文件,使用创建它们的工具1461* 重新登录该配置文件,然后重试:在[提供无密钥登录](/docs/zh-CN/authentication#sign-in-without-an-api-key)的机器上,对于由无密钥 Console 登录或 Claude Platform CLI 的 `ant auth login` 写入的配置文件,运行 `/login` 并选择 Anthropic Console 账户;对于其他配置文件,请使用创建它们的工具
1433* 如果管理员配置了配置文件的凭证,请要求他们颁发新凭证1462* 如果该配置文件的凭据由管理员预配,请让他们签发一个新的凭据
1434* 运行 `/status` 以确认活跃凭证源和配置文件名称1463* 运行 `/status`,确认当前生效的凭据来源和配置文件名称
1435* 要停止使用配置文件,如果您设置了 `ANTHROPIC_PROFILE`,则取消设置它,然后以其他方式进行身份验证,例如 `/login` 或 `ANTHROPIC_API_KEY`1464* 如需停止使用该配置文件,请取消设置 `ANTHROPIC_PROFILE`(如果您设置过),然后以其他方式进行身份验证,例如 `/login` 或 `ANTHROPIC_API_KEY`
1436 1465
1437<h3 id="oauth-scope-requirement">1466<h3 id="oauth-scope-requirement">
1438 OAuth 范围要求1467 OAuth 作用域要求
1439</h3>1468</h3>
1440 1469
1441存储的令牌早于较新功能需要的权限范围:1470已存储的令牌早于某个新功能所需的权限作用域:
1442 1471
1443```text theme={null}1472```text theme={null}
1444OAuth token does not meet scope requirement: user:profile1473OAuth token does not meet scope requirement: user:profile
1445```1474```
1446 1475
1447**应该做什么:**1476**解决方法:**
1448 1477
1449* 运行 `/login` 以获取具有当前范围的新令牌。您不需要先登出。1478* 运行 `/login` 获取具有当前作用域的新令牌。您无需先注销。
1450 1479
1451<h3 id="claude-ai-rejected-the-session-token">1480<h3 id="claude-ai-rejected-the-session-token">
1452 claude.ai 拒绝了会话令牌1481 claude.ai 拒绝了会话令牌
1453</h3>1482</h3>
1454 1483
1455[claude.ai 连接器](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai) 请求失败,因为 claude.ai 拒绝了您的 Claude Code 登录中的令牌。被拒绝的令牌是您的登录,而不是连接器在 claude.ai 中的自己的授权,因此再次授权连接器不会解决它。在 `/mcp` 中,连接器显示为 `session token rejected`,其详细视图读作:1484[claude.ai 连接器](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai)请求失败,因为 claude.ai 拒绝了来自您 Claude Code 登录的令牌。被拒绝的令牌是您的登录,而不是该连接器在 claude.ai 中自身的授权,因此重新授权连接器并不能解决问题。在 `/mcp` 中,该连接器显示为 `session token rejected`,其详细信息视图显示:
1456 1485
1457```text theme={null}1486```text theme={null}
1458claude.ai rejected the session token. Run /login, then reconnect.1487claude.ai rejected the session token. Run /login, then reconnect.
1459```1488```
1460 1489
1461**应该做什么:**1490**解决方法:**
1462 1491
1463* 运行 `/login` 再次登录1492* 运行 `/login` 重新登录
1464* 从 `/mcp` 重新连接连接器,或运行 `/mcp reconnect <server>`。在您再次登录之前重新连接会使连接器处于相同状态。`/mcp` 面板的 **Reconnect** 选项报告 `your claude.ai session token was rejected`;输入的 `/mcp reconnect <server>` 形式报告成功重新连接,即使令牌仍然被拒绝。1493* 从 `/mcp` 重新连接该连接器,或运行 `/mcp reconnect <server>`。在重新登录之前重新连接,连接器会保持相同状态。`/mcp` 面板的 **Reconnect** 选项会报告 `your claude.ai session token was rejected`;而键入的 `/mcp reconnect <server>` 形式会报告重新连接成功,尽管令牌仍然被拒绝。
1465 1494
1466在 v2.1.222 之前,Claude Code 改为将连接器标记为需要身份验证,这指向您连接器的授权流程,即使完成它也不会解决状态。1495在 v2.1.222 之前,Claude Code 会将该连接器标记为需要身份验证,这会引导您进入连接器的授权流程,而完成该流程并不能解决此状态。
1467 1496
1468<h3 id="mcp-server-needs-you-to-sign-in-again">1497<h3 id="mcp-server-needs-you-to-sign-in-again">
1469 MCP 服务器需要您再次登录1498 MCP 服务器需要您重新登录
1470</h3>1499</h3>
1471 1500
1472远程 [MCP 服务器](/docs/zh-CN/mcp) 在会话中期拒绝了工具调用上的凭证,通常是因为登录或令牌过期或令牌缺少工具需要的权限。工具调用失败,`/mcp` 将服务器标记为 [需要身份验证](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers)。1501某个远程 [MCP 服务器](/docs/zh-CN/mcp)在会话中途的工具调用中拒绝了凭据,通常是因为登录或令牌已过期,或令牌缺少工具所需的权限。该工具调用失败,`/mcp` 会将该服务器标记为[需要身份验证](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers)。
1473 1502
1474对于您从 Claude Code 登录的服务器,包括 claude.ai 连接器,登录已过期或被撤销:1503对于您从 Claude Code 登录的服务器(包括 claude.ai 连接器),登录已过期或被撤销:
1475 1504
1476```text theme={null}1505```text theme={null}
1477MCP server "<name>" needs you to sign in again (run /mcp to re-authenticate)1506MCP server "<name>" needs you to sign in again (run /mcp to re-authenticate)
1478```1507```
1479 1508
1480运行 `/mcp`,选择服务器,并从其菜单再次登录。1509运行 `/mcp`,选择该服务器,然后从其菜单中重新登录。
1481 1510
1482对于使用 [`headersHelper`](/docs/zh-CN/mcp#use-dynamic-headers-for-custom-authentication) 脚本配置的服务器,Claude Code 已在显示此之前重新运行 helper 并重试调用一次:1511对于配置了 [`headersHelper`](/docs/zh-CN/mcp#use-dynamic-headers-for-custom-authentication) 脚本的服务器,Claude Code 在显示以下消息之前已经重新运行过该 helper 并重试了一次调用:
1483 1512
1484```text theme={null}1513```text theme={null}
1485MCP server "<name>" rejected the credential from its headersHelper (check the helper and run /mcp to reconnect, or to authenticate if the server also uses OAuth)1514MCP server "<name>" rejected the credential from its headersHelper (check the helper and run /mcp to reconnect, or to authenticate if the server also uses OAuth)
1486```1515```
1487 1516
1488检查 helper 返回服务器接受的凭证,然后从 `/mcp` 重新连接,这会再次运行 helper。1517检查该 helper 是否返回服务器接受的凭据,然后从 `/mcp` 重新连接,这会再次运行该 helper。
1489 1518
1490对于在其配置中具有静态 `Authorization` 标头的服务器:1519对于在配置中带有静态 `Authorization` 标头的服务器:
1491 1520
1492```text theme={null}1521```text theme={null}
1493MCP server "<name>" rejected the Authorization header in its config (update it, then run /mcp to reconnect)1522MCP server "<name>" rejected the Authorization header in its config (update it, then run /mcp to reconnect)
1494```1523```
1495 1524
1496在配置服务器的位置更新标头值,然后从 `/mcp` 重新连接。1525在配置该服务器的位置更新标头值,然后从 `/mcp` 重新连接。
1497 1526
1498在 v2.1.273 之前,过期的登录、`headersHelper` 和 `Authorization` 标头情况都显示 `MCP server "<name>" requires re-authorization (token expired)`。1527在 v2.1.273 之前,登录过期、`headersHelper` 和 `Authorization` 标头这几种情况都显示 `MCP server "<name>" requires re-authorization (token expired)`。
1499 1528
1500服务器也可以使用 HTTP 403 `insufficient_scope` 拒绝工具调用,以要求您授权范围,有时是您的令牌已列出的范围。消息命名该范围:1529服务器也可能以 HTTP 403 `insufficient_scope` 拒绝工具调用,要求您授权某个作用域,有时该作用域甚至已列在您的令牌中。消息会指出该作用域:
1501 1530
1502```text theme={null}1531```text theme={null}
1503MCP server "<name>" needs additional permissions (scope: "<scope>") — run /mcp to re-authenticate1532MCP server "<name>" needs additional permissions (scope: "<scope>") — run /mcp to re-authenticate
1504```1533```
1505 1534
1506运行 `/mcp`,选择服务器,并从其菜单再次进行身份验证。1535运行 `/mcp`,选择该服务器,然后从其菜单中重新进行身份验证。
1507 1536
1508当服务器的配置既不设置 [`oauth.scopes`](/docs/zh-CN/mcp#restrict-oauth-scopes) 也不设置 [`authServerMetadataUrl`](/docs/zh-CN/mcp#override-oauth-metadata-discovery) 时,Claude Code 请求服务器命名的范围。使用任一设置,Claude Code 改为请求该设置的范围。如果您固定了 `oauth.scopes`,在再次进行身份验证之前将缺失的范围添加到该列表。1537当服务器的配置既未设置 [`oauth.scopes`](/docs/zh-CN/mcp#restrict-oauth-scopes) 也未设置 [`authServerMetadataUrl`](/docs/zh-CN/mcp#override-oauth-metadata-discovery) 时,Claude Code 会请求服务器指出的作用域。如果设置了其中任一项,Claude Code 会改为请求该设置中的作用域。如果您固定了 `oauth.scopes`,请在重新进行身份验证之前将缺失的作用域添加到该列表中。
1509 1538
1510在 v2.1.274 之前,这种情况显示 `needs you to sign in again` 消息,在 v2.1.273 之前它显示 `requires re-authorization (token expired)`,如其他情况。1539在 v2.1.274 之前,这种情况显示 `needs you to sign in again` 消息;在 v2.1.273 之前,它与其他情况一样显示 `requires re-authorization (token expired)`。
1511 1540
1512<h3 id="mcp-server-url-is-missing-or-not-a-valid-url">1541<h3 id="mcp-server-url-is-missing-or-not-a-valid-url">
1513 MCP 服务器 URL 缺失或不是有效的 URL1542 MCP 服务器 URL 缺失或不是有效的 URL
1514</h3>1543</h3>
1515 1544
1516Claude Code 拒绝为远程 MCP 服务器启动 OAuth 登录,因为服务器的配置 `url` 不解析为 URL。除非 Claude Code 有更具体的配置问题要为服务器报告,否则在您的 shell 中运行 [`claude mcp login <name>`](/docs/zh-CN/mcp#authenticate-from-the-command-line) 会将拒绝打印为:1545Claude Code 拒绝为某个远程 MCP 服务器启动 OAuth 登录,因为该服务器配置的 `url` 无法解析为 URL。除非 Claude Code 对该服务器有更具体的配置问题需要报告,否则在您的 shell 中运行 [`claude mcp login <name>`](/docs/zh-CN/mcp#authenticate-from-the-command-line) 会将该拒绝输出为:
1517 1546
1518```text theme={null}1547```text theme={null}
1519Couldn't complete authentication for "<name>": This server's URL is missing or not a valid URL, so sign-in can't start. Fix the URL in its MCP config (or set the environment variable it uses) and try again.1548Couldn't complete authentication for "<name>": This server's URL is missing or not a valid URL, so sign-in can't start. Fix the URL in its MCP config (or set the environment variable it uses) and try again.
1520```1549```
1521 1550
1522**应该做什么:**1551**解决方法:**
1523 1552
1524* 将条目的 `url` 设置为服务器的真实端点,其中配置服务器,或设置其 [`${VAR}` 引用](/docs/zh-CN/mcp#environment-variable-expansion-in-mcp-json) 命名的环境变量,然后再次运行登录。1553* 在配置该服务器的位置,将该条目的 `url` 设置为服务器的真实端点,或设置其 [`${VAR}` 引用](/docs/zh-CN/mcp#environment-variable-expansion-in-mcp-json)所指的环境变量,然后再次运行登录。
1525 1554
1526<h3 id="issuer-mismatch-in-authorization-response">1555<h3 id="issuer-mismatch-in-authorization-response">
1527 授权响应中的发行者不匹配1556 授权响应中的颁发者不匹配
1528</h3>1557</h3>
1529 1558
1530在 [MCP OAuth 登录](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers) 期间,授权服务器重定向回 Claude Code,其中 `iss` 参数不命名 Claude Code 从服务器的 OAuth 元数据期望的发行者。此步骤中的错误发行者是授权服务器混合攻击的样子,因此 Claude Code 失败登录而不是交换授权代码。Claude Code 在浏览器登录后在 `/mcp` 服务器菜单中显示错误:1559在 [MCP OAuth 登录](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers)期间,授权服务器重定向回 Claude Code 时所携带的 `iss` 参数与 Claude Code 根据服务器 OAuth 元数据所期望的颁发者不一致。此步骤中出现错误的颁发者正是授权服务器混淆攻击(mix-up attack)的表现形式,因此 Claude Code 会让登录失败,而不是交换授权码。Claude Code 会在浏览器登录后,在 `/mcp` 服务器菜单中显示该错误:
1531 1560
1532```text theme={null}1561```text theme={null}
1533Issuer mismatch in authorization response (RFC 9207): expected "https://auth.example.com", received "https://other.example.com"1562Issuer mismatch in authorization response (RFC 9207): expected "https://auth.example.com", received "https://other.example.com"
1534```1563```
1535 1564
1536`expected` 是来自服务器的 OAuth 元数据的发行者,`received` 是重定向携带的 `iss` 值。其重定向不携带 `iss` 参数的登录通过检查,除非服务器的元数据设置 `authorization_response_iss_parameter_supported`,在这种情况下 Claude Code 失败登录。1565`expected` 是来自服务器 OAuth 元数据的颁发者,`received` 是重定向所携带的 `iss` 值。重定向未携带 `iss` 参数的登录会通过检查,除非服务器的元数据设置了 `authorization_response_iss_parameter_supported`,这种情况下 Claude Code 会让登录失败。
1537 1566
1538**应该做什么:**1567**解决方法:**
1539 1568
1540* 从 `/mcp` 再次尝试登录1569* 从 `/mcp` 再次尝试登录
1541* 如果错误重复,将其报告给服务器操作员。修复是服务器端的:授权服务器必须在 `iss` 参数中返回与在其元数据中宣传的相同发行者1570* 如果错误重复出现,请向服务器运营方报告。需要在服务器端修复:授权服务器必须在 `iss` 参数中返回与其元数据中公布的相同的颁发者
1542* 要在修复服务器时连接,使用 [`MCP_SDK_GENERATION=v1`](/docs/zh-CN/env-vars) 启动 Claude Code,其 [运行时](/docs/zh-CN/mcp#mcp-client-runtimes) 不运行此检查。这消除了对混合攻击的保护,因此更喜欢服务器端修复1571* 如需在服务器修复期间进行连接,请使用 [`MCP_SDK_GENERATION=v1`](/docs/zh-CN/env-vars) 启动 Claude Code,其[运行时](/docs/zh-CN/mcp#mcp-client-runtimes)不执行此检查。这会移除一项针对混淆攻击的防护,因此请优先采用服务器端修复
1543 1572
1544在 v2.1.232 之前,Claude Code 仅在逐步推出中或当您设置 `MCP_SDK_GENERATION=v2` 时使用 v2 运行时。1573在 v2.1.232 之前,Claude Code 仅在逐步推出时或您设置 `MCP_SDK_GENERATION=v2` 时才使用 v2 运行时。
1545 1574
1546<h3 id="refusing-to-send-credentials-to-non-https-token-endpoint">1575<h3 id="refusing-to-send-credentials-to-non-https-token-endpoint">
1547 拒绝向非 https 令牌端点发送凭证1576 拒绝向非 https 令牌端点发送凭据
1548</h3>1577</h3>
1549 1578
1550在 [v2 运行时](/docs/zh-CN/mcp#mcp-client-runtimes) 上,Claude Code 仅向通过 HTTPS 或在 `localhost`、`127.0.0.1` 或 `::1` 处提供的令牌端点发送 [MCP OAuth](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers) 令牌请求。此消息意味着服务器的令牌端点都不是,因此 Claude Code 在发送请求前停止。这发生在浏览器登录之后,因此浏览器步骤首先成功,并且每当 Claude Code 刷新服务器的令牌时再次发生。1579在 [v2 运行时](/docs/zh-CN/mcp#mcp-client-runtimes)上,Claude Code 只会将 [MCP OAuth](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers) 令牌请求发送到通过 HTTPS 提供服务的令牌端点,或位于 `localhost`、`127.0.0.1` 或 `::1` 的令牌端点。此消息表示服务器的令牌端点两者都不是,因此 Claude Code 在发送请求前就停止了。这发生在浏览器登录之后,因此浏览器步骤会先成功,并且每当 Claude Code 刷新该服务器的令牌时都会再次发生。
1551 1580
1552在其完整形式中,消息来自 MCP SDK 并引用它拒绝的令牌端点。在调试日志中,它遵循 `Error during auth completion:` 用于登录或 `Token refresh failed:` 用于刷新。在您的 shell 中,`claude mcp login <name>` 在 `Couldn't complete authentication for "<name>":` 之后打印它,在会话中,`/mcp` 在服务器的菜单下显示它:1581该消息的完整形式来自 MCP SDK,并会引用它拒绝的令牌端点。在调试日志中,对于登录,它跟在 `Error during auth completion:` 之后;对于刷新,它跟在 `Token refresh failed:` 之后。在您的 shell 中,`claude mcp login <name>` 会在 `Couldn't complete authentication for "<name>":` 之后输出它;在会话中,`/mcp` 会在服务器菜单下显示它:
1553 1582
1554```text theme={null}1583```text theme={null}
1555Refusing to send credentials to non-https token endpoint 'http://192.168.1.50:8123/oauth/token'. OAuth token requests MUST use TLS (localhost / 127.0.0.1 / ::1 are exempt).1584Refusing to send credentials to non-https token endpoint 'http://192.168.1.50:8123/oauth/token'. OAuth token requests MUST use TLS (localhost / 127.0.0.1 / ::1 are exempt).
1556```1585```
1557 1586
1558Claude Code 将具有查询字符串或长随机外观路径段的服务器 URL 视为可能的秘密。对于这样的服务器,它在显示或记录它们之前会编辑 MCP SDK 引发的登录错误。此错误然后读作可能在版本之间更改的短名称,例如 `io`,后跟 `from the MCP SDK for` 和编辑的服务器 URL。MCP SDK 的其他错误在那里采用相同的形状。编辑的消息只能是此错误,当服务器的令牌端点是纯 `http://` 在 `localhost`、`127.0.0.1` 或 `::1` 以外的地址时。1587Claude Code 会将带有查询字符串或较长的随机外观路径段的服务器 URL 视为可能是机密的。对于此类服务器,它会在显示或记录 MCP SDK 引发的登录错误之前对其进行脱敏。此时该错误会显示为一个可能因版本而变化的简短名称(例如 `io`),后跟 `from the MCP SDK for` 和经过脱敏的服务器 URL。来自 MCP SDK 的其他错误在这种情况下也采用相同的形式。只有当服务器的令牌端点是位于 `localhost`、`127.0.0.1` 或 `::1` 以外地址的普通 `http://` 时,脱敏后的消息才可能是此错误。
1559 1588
1560**应该做什么:**1589**解决方法:**
1561 1590
1562* 通过 HTTPS 提供该令牌端点,例如通过将服务器放在终止 TLS 的反向代理或隧道后面,并配置服务器以宣传 `https://` 地址1591* 通过 HTTPS 提供该令牌端点,例如将服务器置于终止 TLS 的反向代理或隧道之后,并配置服务器公布 `https://` 地址
1563* 要在不更改服务器的情况下连接,使用 [`MCP_SDK_GENERATION=v1`](/docs/zh-CN/env-vars) 启动 Claude Code,其 [运行时](/docs/zh-CN/mcp#mcp-client-runtimes) 不应用此规则并通过纯 HTTP 发送令牌请求。该选择持续到您退出并应用于每个服务器。v1 运行时也跳过 [发行者检查](#issuer-mismatch-in-authorization-response),因此更喜欢通过 HTTPS 提供端点1592* 如需在不更改服务器的情况下进行连接,请使用 [`MCP_SDK_GENERATION=v1`](/docs/zh-CN/env-vars) 启动 Claude Code,其[运行时](/docs/zh-CN/mcp#mcp-client-runtimes)不应用此规则,会通过普通 HTTP 发送令牌请求。该选择会持续到您退出为止,并适用于所有服务器。v1 运行时还会跳过[颁发者检查](#issuer-mismatch-in-authorization-response),因此请优先通过 HTTPS 提供该端点
1564 1593
1565<h3 id="aws-credentials-expired-or-invalid">1594<h3 id="aws-credentials-expired-or-invalid">
1566 AWS 凭证已过期或无效1595 AWS 凭据已过期或无效
1567</h3>1596</h3>
1568 1597
1569您的 AWS 会话令牌已过期或被拒绝。此消息出现在来自 [Claude Platform on AWS](/docs/zh-CN/claude-platform-on-aws) 或 [Mantle 端点](/docs/zh-CN/amazon-bedrock#use-the-mantle-endpoint) 的 401,这是这些提供商报告过期安全令牌的方式。1598您的 AWS 会话令牌已过期或被拒绝。当 [Claude Platform on AWS](/docs/zh-CN/claude-platform-on-aws) 或 [Mantle 端点](/docs/zh-CN/amazon-bedrock#use-the-mantle-endpoint)返回 401 时会出现此消息,这是这些提供商报告安全令牌过期的方式。
1570 1599
1571中间的操作提示因您的设置而异。稳定部分是前导 `AWS credentials expired or invalid`:1600中间的操作提示因您的设置而异。稳定不变的部分是开头的 `AWS credentials expired or invalid`:
1572 1601
1573```text theme={null}1602```text theme={null}
1574AWS credentials expired or invalid · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · API Error: 401 ...1603AWS credentials expired or invalid · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · API Error: 401 ...
1575```1604```
1576 1605
1577在 v2.1.273 之前,仅当配置了 `awsAuthRefresh` 时才出现此消息。1606在 v2.1.273 之前,只有在配置了 `awsAuthRefresh` 时才会出现此消息。
1578 1607
1579**应该做什么:**1608**解决方法:**
1580 1609
1581* 如果提示说凭证由此环境管理,启动 Claude Code 的应用拥有凭证,此处的其他步骤不适用:重试或联系您的管理员1610* 如果提示说明凭据由此环境管理,则凭据归启动 Claude Code 的应用所有,此处的其他步骤不适用:请重试,或联系您的管理员
1582* 如果设置了 [`awsAuthRefresh`](/docs/zh-CN/amazon-bedrock#advanced-credential-configuration),在另一个终端中运行消息中命名的命令,例如 `aws sso login --profile myprofile`,并完成浏览器登录,然后重试。否则自己刷新您使用的 AWS 凭证:您的 SSO 登录、访问密钥、API 密钥或代理令牌1611* 如果设置了 [`awsAuthRefresh`](/docs/zh-CN/amazon-bedrock#advanced-credential-configuration),请在另一个终端中运行消息中指出的命令(例如 `aws sso login --profile myprofile`)并完成浏览器登录,然后重试。否则,请自行刷新您所使用的 AWS 凭据:您的 SSO 登录、访问密钥、API 密钥或代理令牌
1583* 在交互式会话中设置 `awsAuthRefresh`,您可以改为运行 `/login`,选择 **3rd-party platform**,然后在 **Using 3rd-party platforms** 下选择 **Claude Platform on AWS · refresh credentials** 以运行相同的命令而不重新启动 Claude Code。请参阅 [配置 AWS 凭证](/docs/zh-CN/claude-platform-on-aws#1-configure-aws-credentials)1612* 在设置了 `awsAuthRefresh` 的交互式会话中,您也可以运行 `/login`,选择 **3rd-party platform**,然后在 **Using 3rd-party platforms** 下选择 **Claude Platform on AWS · refresh credentials**,无需重启 Claude Code 即可运行同一命令。请参阅[配置 AWS 凭据](/docs/zh-CN/claude-platform-on-aws#1-configure-aws-credentials)
1584* 如果刷新命令成功后错误重复,通过在同一 shell 和配置文件中使用 `aws sts get-caller-identity` 在 Claude Code 外确认身份有效1613* 如果刷新命令成功后错误仍然重复出现,请在同一 shell 和 profile 中运行 `aws sts get-caller-identity`,确认该身份在 Claude Code 之外有效
1585 1614
1586<h3 id="aws-authentication-failed">1615<h3 id="aws-authentication-failed">
1587 AWS 身份验证失败1616 AWS 身份验证失败
1589 1618
1590您的 AWS 提供商返回了 403,或 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock) 返回了 401。1619您的 AWS 提供商返回了 403,或 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock) 返回了 401。
1591 1620
1592Amazon Bedrock 将过期的安全令牌报告为 403,但 403 也是它报告授权拒绝的方式,例如来自缺失 IAM 权限的 `AccessDeniedException`。Claude Code 无法区分这两个原因。1621Amazon Bedrock 将安全令牌过期报告为 403,但 403 也是它报告授权被拒绝的方式,例如因缺少 IAM 权限而产生的 `AccessDeniedException`。Claude Code 无法区分这两种原因。
1593 1622
1594来自 Amazon Bedrock 的 401 也在这里而不是在 [AWS 凭证已过期或无效](#aws-credentials-expired-or-invalid) 下,因为 Amazon Bedrock 不将过期令牌报告为 401。来自该端点的 401 通常来自请求路径中的其他内容,例如公司代理。1623来自 Amazon Bedrock 的 401 也会归到这里,而不是[AWS 凭据已过期或无效](#aws-credentials-expired-or-invalid),因为 Amazon Bedrock 不会将令牌过期报告为 401。来自该端点的 401 通常来自请求路径中的其他环节,例如企业代理。
1595 1624
1596凭证刷新修复过期令牌,无法修复其他原因,因此消息提供两者:1625刷新凭据可以修复令牌过期,但无法修复其他原因,因此消息同时提供了两种方案:
1597 1626
1598```text theme={null}1627```text theme={null}
1599AWS authentication failed · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · if credentials are current, check AWS permissions and model access · API Error: 403 ...1628AWS authentication failed · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · if credentials are current, check AWS permissions and model access · API Error: 403 ...
1600```1629```
1601 1630
1602中间的操作提示因您的设置而异。稳定部分是前导 `AWS authentication failed`。1631中间的操作提示因您的设置而异。稳定不变的部分是开头的 `AWS authentication failed`。
1603 1632
1604当 403 是 Amazon Bedrock 的答案,说您无权访问具有指定模型 ID 的模型时,提示改为告诉您在 Amazon Bedrock 控制台中为您的账户和区域启用模型。1633当 403 是 Amazon Bedrock 表示您无权访问指定模型 ID 的模型时,提示会改为告诉您在 Amazon Bedrock 控制台中为您的账户和区域启用该模型。
1605 1634
1606在 v2.1.273 之前,仅当配置了 `awsAuthRefresh` 时才出现此消息。1635在 v2.1.273 之前,只有在配置了 `awsAuthRefresh` 时才会出现此消息。
1607 1636
1608**应该做什么:**1637**解决方法:**
1609 1638
1610* 如果提示说凭证由此环境管理,启动 Claude Code 的应用拥有凭证,此处的其他步骤不适用:重试或联系您的管理员1639* 如果提示说明凭据由此环境管理,则凭据归启动 Claude Code 的应用所有,此处的其他步骤不适用:请重试,或联系您的管理员
1611* 刷新您的 AWS 凭证以防过期凭证是原因:运行消息中命名的 [`awsAuthRefresh`](/docs/zh-CN/amazon-bedrock#advanced-credential-configuration) 命令(当设置时),或自己刷新您的 SSO 登录、访问密钥、API 密钥或代理令牌1640* 刷新您的 AWS 凭据,以防原因是凭据过期:如果设置了 [`awsAuthRefresh`](/docs/zh-CN/amazon-bedrock#advanced-credential-configuration),请运行消息中指出的该命令;否则请自行刷新您的 SSO 登录、访问密钥、API 密钥或代理令牌
1612* 如果您的凭证是最新的,确认 [IAM 配置](/docs/zh-CN/amazon-bedrock#iam-configuration) 中的 IAM 权限已附加到您使用的身份,并且所选模型已为您的账户和区域启用1641* 如果您的凭据是最新的,请确认 [IAM 配置](/docs/zh-CN/amazon-bedrock#iam-configuration)中的 IAM 权限已附加到您正在使用的身份,并且所选模型已为您的账户和区域启用
1613* 运行 `aws sts get-caller-identity` 以确认您的请求使用哪个身份1642* 运行 `aws sts get-caller-identity`,确认您的请求使用的是哪个身份
1614 1643
1615<h3 id="google-cloud-credentials-expired-or-invalid">1644<h3 id="google-cloud-credentials-expired-or-invalid">
1616 Google Cloud 凭证已过期或无效1645 Google Cloud 凭据已过期或无效
1617</h3>1646</h3>
1618 1647
1619您的 [Google Cloud 的 Agent Platform](/docs/zh-CN/google-vertex-ai) Google Cloud 凭证已过期或被拒绝:请求返回了 401,这是 Agent Platform 报告凭证过期的方式。1648您用于 [Google Cloud's Agent Platform](/docs/zh-CN/google-vertex-ai) 的 Google Cloud 凭据已过期或被拒绝:请求返回了 401,这是 Agent Platform 报告凭据过期的方式。
1620 1649
1621中间的操作提示因您的设置而异。稳定部分是前导 `Google Cloud credentials expired or invalid`:1650中间的操作提示因您的设置而异。稳定不变的部分是开头的 `Google Cloud credentials expired or invalid`:
1622 1651
1623```text theme={null}1652```text theme={null}
1624Google Cloud credentials expired or invalid · refresh your Google Cloud credentials (application default sign-in, or the key file in GOOGLE_APPLICATION_CREDENTIALS) and retry · API Error: 401 ...1653Google Cloud credentials expired or invalid · refresh your Google Cloud credentials (application default sign-in, or the key file in GOOGLE_APPLICATION_CREDENTIALS) and retry · API Error: 401 ...
1625```1654```
1626 1655
1627**应该做什么:**1656**解决方法:**
1628 1657
1629* 如果提示说凭证由此环境管理,启动 Claude Code 的应用拥有凭证,此处的其他步骤不适用:重试或联系您的管理员1658* 如果提示说明凭据由此环境管理,则凭据归启动 Claude Code 的应用所有,此处的其他步骤不适用:请重试,或联系您的管理员
1630* 如果您使用应用默认凭证进行身份验证,运行消息中命名的 [`gcpAuthRefresh`](/docs/zh-CN/google-vertex-ai#advanced-credential-configuration) 命令或 `gcloud auth application-default login`,并完成登录,然后重试1659* 如果您使用应用默认凭据进行身份验证,请运行消息中指出的 [`gcpAuthRefresh`](/docs/zh-CN/google-vertex-ai#advanced-credential-configuration) 命令或 `gcloud auth application-default login` 并完成登录,然后重试
1631* 如果您通过设置了 `CLAUDE_CODE_SKIP_VERTEX_AUTH` 的 [LLM 网关](/docs/zh-CN/llm-gateway) 路由,刷新 `ANTHROPIC_AUTH_TOKEN` 或 `ANTHROPIC_CUSTOM_HEADERS` 中的网关令牌,然后重试1660* 如果您在设置了 `CLAUDE_CODE_SKIP_VERTEX_AUTH` 的情况下通过 [LLM 网关](/docs/zh-CN/llm-gateway)路由,请刷新 `ANTHROPIC_AUTH_TOKEN` 或 `ANTHROPIC_CUSTOM_HEADERS` 中的网关令牌,然后重试
1632* 如果您使用服务账户密钥文件进行身份验证,确认 `GOOGLE_APPLICATION_CREDENTIALS` 指向有效密钥。请参阅 [配置 GCP 凭证](/docs/zh-CN/google-vertex-ai#3-configure-gcp-credentials)1661* 如果您使用服务账号密钥文件进行身份验证,请确认 `GOOGLE_APPLICATION_CREDENTIALS` 指向有效的密钥。请参阅[配置 GCP 凭据](/docs/zh-CN/google-vertex-ai#3-configure-gcp-credentials)
1633* 如果刷新后错误重复,通过在同一 shell 中使用 `gcloud auth application-default print-access-token` 在 Claude Code 外确认身份有效1662* 如果刷新后错误仍然重复出现,请在同一 shell 中运行 `gcloud auth application-default print-access-token`,确认该身份在 Claude Code 之外可以正常工作
1634 1663
1635在 v2.1.273 之前,来自 Agent Platform 的 401 显示通用 `Please run /login` 或 `Failed to authenticate` 消息,无法刷新 Google Cloud 凭证。1664在 v2.1.273 之前,来自 Agent Platform 的 401 会改为显示通用的 `Please run /login` 或 `Failed to authenticate` 消息,而这些消息无法刷新 Google Cloud 凭据。
1636 1665
1637<h3 id="google-cloud-authentication-failed">1666<h3 id="google-cloud-authentication-failed">
1638 Google Cloud 身份验证失败1667 Google Cloud authentication failed
1639</h3>1668</h3>
1640 1669
1641[Google Cloud 的 Agent Platform](/docs/zh-CN/google-vertex-ai) 返回了 403,它用于授权拒绝而不是过期凭证。通常您进行身份验证的身份缺少 IAM 权限,或模型未为您的项目启用。1670[Google Cloud 的 Agent Platform](/docs/zh-CN/google-vertex-ai) 返回了 403,该平台使用此状态码表示授权被拒绝,而非凭据过期。通常是您用于身份验证的身份缺少某项 IAM 权限,或者您的项目未启用该模型。
1642 1671
1643中间的操作提示因您的设置而异。稳定部分是前导 `Google Cloud authentication failed`:1672中间的操作提示因您的设置而异。固定不变的部分是开头的 `Google Cloud authentication failed`:
1644 1673
1645```text theme={null}1674```text theme={null}
1646Google Cloud authentication failed · refresh your Google Cloud credentials (application default sign-in, or the key file in GOOGLE_APPLICATION_CREDENTIALS) and retry · if credentials are current, check GCP IAM permissions and Vertex AI model access · API Error: 403 ...1675Google Cloud authentication failed · refresh your Google Cloud credentials (application default sign-in, or the key file in GOOGLE_APPLICATION_CREDENTIALS) and retry · if credentials are current, check GCP IAM permissions and Vertex AI model access · API Error: 403 ...
1647```1676```
1648 1677
1649**应该做什么:**1678**解决方法:**
1650 1679
1651* 如果提示说凭证由此环境管理,启动 Claude Code 的应用拥有凭证,此处的其他步骤不适用:重试或联系您的管理员1680* 如果提示表明凭据由当前环境管理,则凭据归启动 Claude Code 的应用所有,此处的其他步骤不适用:请重试,或联系您的管理员
1652* 确认 [IAM 配置](/docs/zh-CN/google-vertex-ai#iam-configuration) 中的角色已授予您进行身份验证的身份1681* 确认 [IAM 配置](/docs/zh-CN/google-vertex-ai#iam-configuration)中的角色已授予您用于身份验证的身份
1653* 确认模型已为您的项目启用。请参阅 [请求模型访问](/docs/zh-CN/google-vertex-ai#2-request-model-access)1682* 确认您的项目已启用该模型。请参阅[申请模型访问权限](/docs/zh-CN/google-vertex-ai#2-request-model-access)
1654 1683
1655在 v2.1.273 之前,来自 Agent Platform 的 403 显示通用 `Please run /login` 或 `Failed to authenticate` 消息,无法刷新 Google Cloud 凭证。1684在 v2.1.273 之前,来自 Agent Platform 的 403 会改为显示通用的 `Please run /login` 或 `Failed to authenticate` 消息,而这些操作无法刷新 Google Cloud 凭据。
1656 1685
1657<h3 id="microsoft-foundry-authentication-failed">1686<h3 id="microsoft-foundry-authentication-failed">
1658 Microsoft Foundry 身份验证失败1687 Microsoft Foundry authentication failed
1659</h3>1688</h3>
1660 1689
1661[Microsoft Foundry](/docs/zh-CN/microsoft-foundry) 返回了 401 或 403:请求上的 Azure 凭证被拒绝,或其背后的身份无权访问 Foundry 资源。`/login` 无法铸造 Azure 凭证。中间的操作提示因您的设置而异。稳定部分是前导 `Microsoft Foundry authentication failed`:1690[Microsoft Foundry](/docs/zh-CN/microsoft-foundry) 返回了 401 或 403:请求中的 Azure 凭据被拒绝,或者其背后的身份无权访问 Foundry 资源。`/login` 无法生成 Azure 凭据。中间的操作提示因您的设置而异。固定不变的部分是开头的 `Microsoft Foundry authentication failed`:
1662 1691
1663```text theme={null}1692```text theme={null}
1664Microsoft Foundry authentication failed · refresh your Foundry credential (ANTHROPIC_FOUNDRY_AUTH_TOKEN, ANTHROPIC_FOUNDRY_API_KEY, Azure sign-in for Entra, or your proxy token) and retry · if credentials are current, check access to the Foundry resource · API Error: 401 ...1693Microsoft Foundry authentication failed · refresh your Foundry credential (ANTHROPIC_FOUNDRY_AUTH_TOKEN, ANTHROPIC_FOUNDRY_API_KEY, Azure sign-in for Entra, or your proxy token) and retry · if credentials are current, check access to the Foundry resource · API Error: 401 ...
1665```1694```
1666 1695
1667**应该做什么:**1696**解决方法:**
1668 1697
1669* 如果提示说凭证由此环境管理,启动 Claude Code 的应用拥有凭证,此处的其他步骤不适用:重试或联系您的管理员1698* 如果提示表明凭据由当前环境管理,则凭据归启动 Claude Code 的应用所有,此处的其他步骤不适用:请重试,或联系您的管理员
1670* 刷新您在 [配置 Azure 凭证](/docs/zh-CN/microsoft-foundry#2-configure-azure-credentials) 中配置的凭证:轮换 `ANTHROPIC_FOUNDRY_API_KEY`、铸造新的 `ANTHROPIC_FOUNDRY_AUTH_TOKEN` 或运行 `az login` 以便默认 Microsoft Entra 凭证链可以再次登录1699* 刷新您在[配置 Azure 凭据](/docs/zh-CN/microsoft-foundry#2-configure-azure-credentials)中配置的凭据:轮换 `ANTHROPIC_FOUNDRY_API_KEY`、生成新的 `ANTHROPIC_FOUNDRY_AUTH_TOKEN`,或运行 `az login` 以便默认的 Microsoft Entra 凭据链可以重新登录
1671* 如果凭证是最新的,确认身份有权访问 Foundry 资源。请参阅 [Azure RBAC 配置](/docs/zh-CN/microsoft-foundry#azure-rbac-configuration)1700* 如果凭据有效,请确认该身份有权访问 Foundry 资源。请参阅 [Azure RBAC 配置](/docs/zh-CN/microsoft-foundry#azure-rbac-configuration)
1672 1701
1673在 v2.1.273 之前,来自 Microsoft Foundry 的 401 或 403 显示通用 `Please run /login` 或 `Failed to authenticate` 消息,无法刷新 Azure 凭证。1702在 v2.1.273 之前,来自 Microsoft Foundry 的 401 或 403 会改为显示通用的 `Please run /login` 或 `Failed to authenticate` 消息,而这些操作无法刷新 Azure 凭据。
1674 1703
1675<h3 id="could-not-load-aws-or-google-cloud-credentials">1704<h3 id="could-not-load-aws-or-google-cloud-credentials">
1676 无法加载 AWS 或 Google Cloud 凭证1705 Could not load AWS or Google Cloud credentials
1677</h3>1706</h3>
1678 1707
1679Claude Code 无法从 AWS 凭证提供商链或从它运行的机器上的 Google 应用默认凭证获取可用凭证,因此没有请求到达您的云提供商。Claude Code 清除其缓存凭证并在显示此消息之前重试两次。`·` 之后的详细信息命名具体原因,例如过期的 SSO 会话、缺失的应用默认凭证报告为 `Could not load the default credentials` 或被撤销的登录报告为 `invalid_grant`:1708Claude Code 无法在其运行的机器上从 AWS 凭据提供程序链或 Google 应用默认凭据中获取可用的凭据,因此没有请求到达您的云提供商。Claude Code 会清除其缓存的凭据并重试两次,然后才显示此消息。`·` 之后的详细信息会指出具体原因,例如 SSO 会话已过期、缺少应用默认凭据(报告为 `Could not load the default credentials`),或登录已被撤销(报告为 `invalid_grant`):
1680 1709
1681```text theme={null}1710```text theme={null}
1682API Error: Could not load AWS credentials · Could not load credentials from any providers. Check or refresh your AWS credentials and try again.1711API Error: Could not load AWS credentials · Could not load credentials from any providers. Check or refresh your AWS credentials and try again.
1683API Error: Could not load Google Cloud credentials · invalid_grant. Check or refresh your Google Cloud credentials and try again.1712API Error: Could not load Google Cloud credentials · invalid_grant. Check or refresh your Google Cloud credentials and try again.
1684```1713```
1685 1714
1686在 [非交互式模式](/docs/zh-CN/headless) 中使用 `-p` 和在 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,结构化错误代码为 `cloud_credential_error`。在 v2.1.267 之前,消息仅显示 `API Error:` 之后的详细信息文本,结构化代码为 `server_error` 或 `unknown`。1715在使用 `-p` 的[非交互模式](/docs/zh-CN/headless)和 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 中,结构化错误代码为 `cloud_credential_error`。在 v2.1.267 之前,该消息仅显示 `API Error:` 之后的详细文本,结构化代码为 `server_error` 或 `unknown`。
1687 1716
1688**应该做什么:**1717**解决方法:**
1689 1718
1690* 运行您的提供商的登录命令,例如 `aws sso login --profile myprofile` 或 `gcloud auth application-default login`,然后重试。[Bedrock、Agent Platform 或 Foundry 凭证未加载](/docs/zh-CN/troubleshoot-install#bedrock-agent-platform-or-foundry-credentials-not-loading) 显示如何在 Claude Code 外确认凭证1719* 运行您的提供商的登录命令,例如 `aws sso login --profile myprofile` 或 `gcloud auth application-default login`,然后重试。[Bedrock、Agent Platform 或 Foundry 凭据无法加载](/docs/zh-CN/troubleshoot-install#bedrock-agent-platform-or-foundry-credentials-not-loading)介绍了如何在 Claude Code 之外确认凭据
1691* 如果详细信息读作 `AWS default-chain credential resolve timed out`,链挂起而不是失败,因此改为遵循 [AWS default-chain credential resolve timed out](#aws-default-chain-credential-resolve-timed-out)1720* 如果详细信息为 `AWS default-chain credential resolve timed out`,则表示凭据链卡住了而非失败,请改为按照 [AWS default-chain credential resolve timed out](#aws-default-chain-credential-resolve-timed-out) 进行处理
1692 1721
1693<h3 id="aws-default-chain-credential-resolve-timed-out">1722<h3 id="aws-default-chain-credential-resolve-timed-out">
1694 AWS default-chain credential resolve 超时1723 AWS default-chain credential resolve timed out
1695</h3>1724</h3>
1696 1725
1697AWS 默认凭证提供商链在 60 秒内未生成凭证,因此 Claude Code 停止了解析并失败了请求。此超时是 [无法加载 AWS 或 Google Cloud 凭证](#could-not-load-aws-or-google-cloud-credentials) 的一个原因。故障是本地凭证解析:请求从未到达 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock)、[Claude Platform on AWS](/docs/zh-CN/claude-platform-on-aws) 或 [Mantle 端点](/docs/zh-CN/amazon-bedrock#use-the-mantle-endpoint)。Claude Code 在此错误出现之前清除其 [凭证缓存](/docs/zh-CN/amazon-bedrock#credential-caching-and-resolution-timeout) 并重试,因此当您看到它时链已在重复尝试中停滞。1726AWS 默认凭据提供程序链未能在 60 秒内生成凭据,因此 Claude Code 停止了解析并使请求失败。此超时是 [Could not load AWS or Google Cloud credentials](#could-not-load-aws-or-google-cloud-credentials) 的原因之一。失败发生在本地凭据解析阶段:请求从未到达 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock)、[Claude Platform on AWS](/docs/zh-CN/claude-platform-on-aws) 或 [Mantle 端点](/docs/zh-CN/amazon-bedrock#use-the-mantle-endpoint)。Claude Code 会在此错误出现之前清除其[凭据缓存](/docs/zh-CN/amazon-bedrock#credential-caching-and-resolution-timeout)并重试,因此当您看到此错误时,凭据链已在多次尝试中停滞。
1698 1727
1699```text theme={null}1728```text theme={null}
1700API Error: Could not load AWS credentials · AWS default-chain credential resolve timed out. Check or refresh your AWS credentials and try again.1729API Error: Could not load AWS credentials · AWS default-chain credential resolve timed out. Check or refresh your AWS credentials and try again.
1701```1730```
1702 1731
1703常见原因是您的 AWS 配置文件中的 `credential_process` 命令等待它无法接收的输入,以及其实例元数据服务 (IMDS) 从不回答链探针的容器或 VM。1732常见原因包括:AWS 配置文件中的 `credential_process` 命令在等待它无法接收的输入,以及容器或虚拟机的实例元数据服务(IMDS)始终未响应凭据链的探测。
1704 1733
1705在 v2.1.267 之前,消息读作 `API Error: AWS default-chain credential resolve timed out`。1734在 v2.1.267 之前,该消息为 `API Error: AWS default-chain credential resolve timed out`。
1706在 v2.1.207 之前,停滞的链使请求无限期等待而不是失败。1735在 v2.1.207 之前,停滞的凭据链会让请求无限期等待,而不是失败。
1707 1736
1708**应该做什么:**1737**解决方法:**
1709 1738
1710* 在同一 shell 中使用相同的 `AWS_PROFILE` 运行 `aws sts get-caller-identity`。如果它也挂起,修复配置文件;提示交互式的 `credential_process` 命令是常见原因。1739* 在同一 shell 中使用相同的 `AWS_PROFILE` 运行 `aws sts get-caller-identity`。如果它也卡住,请修复该配置文件;以交互方式提示输入的 `credential_process` 命令是常见原因。
1711* 在启动 Claude Code 之前完成登录步骤,例如 `aws sso login --profile myprofile`,以便链从本地 SSO 缓存而不是等待浏览器流解析1740* 在启动 Claude Code 之前完成登录步骤,例如 `aws sso login --profile myprofile`
1712* 如果您的链运行合法需要超过 60 秒的交互式登录,例如通过 `aws-vault` 等包装器的 SSO 与 MFA,使用 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-CN/env-vars) 以毫秒为单位提高限制1741* 如果您的凭据链运行的交互式登录确实需要超过 60 秒,例如通过 `aws-vault` 等包装工具进行带 MFA 的 SSO,请使用 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-CN/env-vars) 以毫秒为单位提高该限制
1713 1742
1714<h3 id="bedrock-setup-verification-timed-out-waiting-for-aws">1743<h3 id="bedrock-setup-verification-timed-out-waiting-for-aws">
1715 Bedrock 设置验证超时等待 AWS1744 Bedrock setup verification timed out waiting for AWS
1716</h3>1745</h3>
1717 1746
1718在 [Bedrock 设置向导](/docs/zh-CN/amazon-bedrock#sign-in-with-bedrock) 的凭证验证期间对 AWS 的调用,例如凭证查找或身份检查,未在 60 秒限制内完成。向导停止等待并失败验证步骤:1747在 [Bedrock 设置向导](/docs/zh-CN/amazon-bedrock#sign-in-with-bedrock)的凭据验证过程中,对 AWS 的某个调用(例如凭据查找或身份检查)未能在 60 秒限制内完成。向导停止等待,并使验证步骤失败:
1719 1748
1720```text theme={null}1749```text theme={null}
1721Timed out after 60s waiting for AWS. Check your network and proxy settings; if a credential helper needs longer to prompt you, raise CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS.1750Timed out after 60s waiting for AWS. Check your network and proxy settings; if a credential helper needs longer to prompt you, raise CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS.
1722```1751```
1723 1752
1724该数字反映您的限制:默认 60 秒,或您在 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-CN/env-vars) 中设置的值。1753其中的数字反映您的限制:默认为 60 秒,或您在 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-CN/env-vars) 中设置的值。
1725 1754
1726常见原因是停滞对 AWS 的请求的网络或代理,包括 SSO 令牌刷新,以及仍在等待您看不到的输入的凭证 helper。仅当 helper 合法需要更多时间时才提高限制。1755常见原因包括:网络或代理使发往 AWS 的请求(包括 SSO 令牌刷新)停滞,以及凭据助手仍在等待您看不到的输入。仅当助手确实需要更多时间时才提高该限制。
1727 1756
1728对 AWS 的单个停滞请求也可能在其自己的每请求超时上失败,这在同一步骤上显示较短的消息:1757发往 AWS 的单个停滞请求也可能因其自身的单次请求超时而失败,此时同一步骤会显示一条较短的消息:
1729 1758
1730```text theme={null}1759```text theme={null}
1731A request to AWS timed out. Check your network and proxy settings, then try again.1760A request to AWS timed out. Check your network and proxy settings, then try again.
1732```1761```
1733 1762
1734当相同的超时在模型固定步骤上发生时,向导将模型标记为 `unreachable` 而不是显示任一消息。1763当相同的超时发生在模型固定步骤时,向导会将模型标记为 `unreachable`,而不显示上述任一消息。
1735 1764
1736**应该做什么:**1765**解决方法:**
1737 1766
1738* 在同一 shell 中运行 `aws sts get-caller-identity`。如果它也挂起,停滞在 Claude Code 外,在您的网络、您的代理或您的 AWS 配置文件中的凭证 helper 中;首先修复它。1767* 在同一 shell 中运行 `aws sts get-caller-identity`。如果它也卡住,则停滞发生在 Claude Code 之外,位于您的网络、代理或 AWS 配置文件中的凭据助手;请先修复该问题。
1739* 在打开向导之前完成任何交互式登录,例如 `aws sso login --profile myprofile`1768* 在打开向导之前完成所有交互式登录,例如 `aws sso login --profile myprofile`
1740* 如果您的 AWS 配置文件中的凭证 helper 合法需要超过 60 秒来提示您,使用 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-CN/env-vars) 以毫秒为单位提高限制1769* 如果 AWS 配置文件中的凭据助手确实需要超过 60 秒来提示您,请使用 [`CLAUDE_CODE_AWS_CHAIN_RESOLVE_TIMEOUT_MS`](/docs/zh-CN/env-vars) 以毫秒为单位提高该限制
1741 1770
1742<h3 id="cloud-gateway-session-expired">1771<h3 id="cloud-gateway-session-expired">
1743 Cloud gateway 会话已过期1772 Cloud gateway session expired
1744</h3>1773</h3>
1745 1774
1746您通过 [Claude apps gateway](/docs/zh-CN/claude-apps-gateway) 登录,此机器上保存的网关会话已过期且无法更新,或网关不再接受它,例如在网关的 [JWT 密钥被替换](/docs/zh-CN/claude-apps-gateway-deploy#jwt-secret-rotation) 后。如果您在交互式启动 `claude` 时看到此行,会话已打开且未登录网关:1775您通过 [Claude apps 网关](/docs/zh-CN/claude-apps-gateway)登录,而保存在此机器上的网关会话已过期且无法续期,或者网关不再接受该会话,例如在网关的 [JWT 密钥被替换](/docs/zh-CN/claude-apps-gateway-deploy#jwt-secret-rotation)之后。如果您在以交互方式启动 `claude` 时看到这行消息,则表示会话已以未登录网关的状态打开:
1747 1776
1748```text theme={null}1777```text theme={null}
1749Cloud gateway session expired — run /login to reconnect.1778Cloud gateway session expired — run /login to reconnect.
1750```1779```
1751 1780
1752相同的行可能在会话中期出现,当网关凭证过期且 Claude Code 无法更新它时。1781当网关凭据过期且 Claude Code 无法续期时,同一行消息也可能在会话中途出现。
1753 1782
1754在 [非交互式](/docs/zh-CN/headless) 运行、后台或其他无人值守会话或 `claude` 子命令(除 `claude auth` 外)中,Claude Code 改为在网关不再接受会话时以此消息退出:1783在[非交互](/docs/zh-CN/headless)运行、后台或其他无人值守会话,或除 `claude auth` 以外的 `claude` 子命令中,当网关不再接受该会话时,Claude Code 会改为显示以下消息并退出:
1755 1784
1756```text theme={null}1785```text theme={null}
1757Cloud gateway <url> no longer accepts this session. Start `claude` and sign in again with /login.1786Cloud gateway <url> no longer accepts this session. Start `claude` and sign in again with /login.
1758```1787```
1759 1788
1760**应该做什么:**1789**解决方法:**
1761 1790
1762* 在会话中运行 `/login` 并完成浏览器登录1791* 在会话中运行 `/login` 并完成浏览器登录
1763* 对于非交互式启动,在同一环境中启动 `claude`,运行 `/login`,然后重新运行您的命令1792* 对于非交互式启动,请在同一环境中启动 `claude`,运行 `/login`,然后重新运行您的命令
1764 1793
1765<h3 id="sign-in-timed-out-while-waiting-for-you-to-continue">1794<h3 id="sign-in-timed-out-while-waiting-for-you-to-continue">
1766 登录超时,等待您继续1795 Sign-in timed out while waiting for you to continue
1767</h3>1796</h3>
1768 1797
1769在 [Claude apps gateway](/docs/zh-CN/claude-apps-gateway) 登录期间,网关命名了登录的账户,Claude Code 要求您在保存凭证之前确认它。您将确认保持打开状态超过登录自己的过期,网关未颁发可更新它的刷新令牌,因此当您继续时 Claude Code 未存储任何内容:1798在 [Claude apps 网关](/docs/zh-CN/claude-apps-gateway)登录过程中,网关给出了已登录的账户,Claude Code 在保存凭据之前请您确认该账户。您让确认界面保持打开的时间超过了该次登录自身的有效期,且网关未签发可用于续期的刷新令牌,因此当您继续时,Claude Code 未存储任何内容:
1770 1799
1771```text theme={null}1800```text theme={null}
1772Sign-in timed out while waiting for you to continue. Try again.1801Sign-in timed out while waiting for you to continue. Try again.
1773```1802```
1774 1803
1775**应该做什么:**1804**解决方法:**
1776 1805
1777* 再次运行 `/login` 并在登录过期之前确认账户1806* 再次运行 `/login`,并在登录过期之前确认账户
1778 1807
1779<h3 id="gateway-refused-the-request">1808<h3 id="gateway-refused-the-request">
1780 Gateway 拒绝了请求1809 Gateway refused the request
1781</h3>1810</h3>
1782 1811
1783您通过 [Claude apps gateway](/docs/zh-CN/claude-apps-gateway) 登录,请求返回了 403:网关或其背后的上游拒绝了它。再次登录不会改变拒绝,因此消息指向您的网关管理员:1812您通过 [Claude apps 网关](/docs/zh-CN/claude-apps-gateway)登录,而某个请求返回了 403:网关或其背后的上游拒绝了该请求。重新登录不会改变拒绝结果,因此消息会提示您联系网关管理员:
1784 1813
1785```text theme={null}1814```text theme={null}
1786Gateway refused the request · signing in again won't change this — check with your gateway administrator · API Error: 403 ...1815Gateway refused the request · signing in again won't change this — check with your gateway administrator · API Error: 403 ...
1787```1816```
1788 1817
1789**应该做什么:**1818**解决方法:**
1790 1819
1791* 要求您的网关管理员查找请求。`API Error:` 尾部携带网关返回的拒绝1820* 请您的网关管理员查询该请求。`API Error:` 之后的部分包含网关返回的拒绝信息
1792* 对于管理员:网关上的 [访问控制规则](/docs/zh-CN/claude-apps-gateway-config#http-tuning) 返回 403,[审计日志](/docs/zh-CN/claude-apps-gateway-deploy#logs) 记录其原因,上游的授权拒绝按 [上游错误消息](/docs/zh-CN/claude-apps-gateway-config#upstream-error-messages) 传递1821* 对于管理员:网关上的[访问控制规则](/docs/zh-CN/claude-apps-gateway-config#http-tuning)会返回 403,[审计日志](/docs/zh-CN/claude-apps-gateway-deploy#logs)会记录该 403 及其原因;上游的授权拒绝会按照[上游错误消息](/docs/zh-CN/claude-apps-gateway-config#upstream-error-messages)中的说明透传
1793 1822
1794在 v2.1.273 之前,网关会话上的 403 显示通用 `Please run /login` 或 `Failed to authenticate` 消息,再次登录不会清除拒绝。1823在 v2.1.273 之前,网关会话上的 403 会改为显示通用的 `Please run /login` 或 `Failed to authenticate` 消息,且重新登录无法消除该拒绝。
1795 1824
1796<h2 id="network-and-connection-errors">1825<h2 id="network-and-connection-errors">
1797 网络和连接错误1826 网络和连接错误
2317API Error: 400 ... Extra inputs are not permitted ... context_management2346API Error: 400 ... Extra inputs are not permitted ... context_management
2318```2347```
2319 2348
2320Claude Code 发送 `context_management` 和 `effort` 等仅限测试版的字段,以及启用它们的 `anthropic-beta` 头。当网关转发正文但删除头时,API 会看到它不识别的字段。2349Claude Code 发送 `context_management` 等仅限测试版的字段,以及启用它们的 `anthropic-beta` 头。当网关转发正文但删除头时,API 会看到它不识别的字段。
2321 2350
2322**要做什么:**2351**要做什么:**
2323 2352
2852 命令行错误2881 命令行错误
2853</h2>2882</h2>
2854 2883
2855这些错误来自 `claude` 命令行及其子命令、您在提示符处提交的命令名称,以及诸如 `/security-review` 之类的命令,这些命令在运行其提示之前通过运行 shell 命令来收集上下文。它们也来自 `/tui`,它会重新启动 CLI。2884这些错误来自 `claude` 命令行及其子命令、您在提示符处提交的命令名称,以及 `/security-review` 等在其提示词运行前通过执行 shell 命令收集上下文的命令。它们也可能来自会重新启动 CLI 的 `/tui`。
2856 2885
2857<h3 id="conflict-between-bg-and-print">2886<h3 id="conflict-between-bg-and-print">
2858 `--bg` 和 `--print` 之间的冲突2887 `--bg` 与 `--print` 冲突
2859</h3>2888</h3>
2860 2889
2861此消息需要 Claude Code v2.1.198 或更高版本。您在同一个 `claude` 调用中将 `--bg` 与 `-p` 或 `--print` 结合使用。`--bg` 启动一个[后台会话](/docs/zh-CN/agent-view#from-your-shell),您稍后可以使用 `claude agents` 附加到该会话,而 `--print` 以[非交互方式](/docs/zh-CN/headless)运行,永远不会启动 `claude agents` 附加到的交互会话。在 v2.1.198 之前,此组合会以静默方式创建一个永远无法附加的后台作业。2890此消息需要 Claude Code v2.1.198 或更高版本。您在同一次 `claude` 调用中将 `--bg` 与 `-p` 或 `--print` 组合使用。`--bg` 会启动一个[后台会话](/docs/zh-CN/agent-view#from-your-shell),之后您可以通过 `claude agents` 连接到该会话;而 `--print` 以[非交互方式](/docs/zh-CN/headless)运行,永远不会启动 `claude agents` 所连接的交互式会话。在 v2.1.198 之前,这种组合会静默创建一个永远无法连接的后台任务。
2862 2891
2863```text theme={null}2892```text theme={null}
2864--bg and --print conflict: --print never starts the interactive session that `claude agents` attaches to, so the job would be unattachable. The prompt is the positional — drop --print: `claude --bg '<task>'`.2893--bg and --print conflict: --print never starts the interactive session that `claude agents` attaches to, so the job would be unattachable. The prompt is the positional — drop --print: `claude --bg '<task>'`.
2865```2894```
2866 2895
2867**应该做什么:**2896**解决方法:**
2897
2898* 去掉 `-p` 或 `--print`。`--bg` 将提示词作为其位置参数,因此 `claude --bg "<task>"` 就是完整的命令。请参阅[从 shell 分派新的 Agent](/docs/zh-CN/agent-view#from-your-shell)。
2899* 若要以非交互方式运行提示词并打印结果,而不是创建后台会话,请去掉 `--bg` 并运行 `claude -p "<task>"`
2900
2901<h3 id="conflict-between-a-system-prompt-flag-and-its-file-form">
2902 系统提示词标志与其文件形式冲突
2903</h3>
2904
2905您在一次 `claude` 调用中同时传入了 [`--append-subagent-system-prompt`](/docs/zh-CN/cli-reference#cli-flags) 和 `--append-subagent-system-prompt-file`,因此 `claude` 以退出码 1 退出,而不会启动会话:
2906
2907```text theme={null}
2908Error: Cannot use both --append-subagent-system-prompt and --append-subagent-system-prompt-file. Please use only one.
2909```
2868 2910
2869* 删除 `-p` 或 `--print`。`--bg` 将提示作为其位置参数,所以 `claude --bg "<task>"` 是完整的命令。请参阅[从您的 shell 分派新代理](/docs/zh-CN/agent-view#from-your-shell)。2911在 v2.1.283 之前,当您将 `--system-prompt` 与 `--system-prompt-file` 一起传入,或将 `--append-system-prompt` 与 `--append-system-prompt-file` 一起传入时,`claude` 也会以同样的方式退出,因为这些标志对会相互冲突,而不是[组合使用](/docs/zh-CN/cli-reference#system-prompt-flags)。在这些版本上,消息会指出您组合使用的那对标志。
2870* 要以非交互方式运行提示并打印结果而不是创建后台会话,请删除 `--bg` 并运行 `claude -p "<task>"`2912
2913**解决方法:**
2914
2915* 保留该标志的一种形式,去掉另一种。若要将固定的提示词文件与每次运行的文本组合,请在启动前将文本合并到文件中,而不是同时传入两个标志
2871 2916
2872<h3 id="invalid-agents-configuration">2917<h3 id="invalid-agents-configuration">
2873 无效的 `--agents` 配置2918 无效的 `--agents` 配置
2874</h3>2919</h3>
2875 2920
2876您传递给 `--agents` 的值无效,所以 `claude` 以代码 1 退出,而不是启动会话。当您传递 `--safe-mode` 或设置 [`CLAUDE_CODE_SAFE_MODE`](/docs/zh-CN/env-vars#variables) 时,Claude Code 会完全忽略 `--agents`。使用 `--resume` 或 `--continue` 时,不会检查内联 JSON 值,会话会启动;从文件读取的值在每次启动时都会被检查。在 v2.1.242 之前,Claude Code 无论如何都会启动会话。2921您传给 `--agents` 的值无效,因此 `claude` 以退出码 1 退出,而不会启动会话。当您传入 `--safe-mode` 或设置 [`CLAUDE_CODE_SAFE_MODE`](/docs/zh-CN/env-vars#variables) 时,Claude Code 会完全忽略 `--agents`。使用 `--resume` 或 `--continue` 时,内联 JSON 值不会被检查,会话会启动;从文件读取的值在每次启动时都会被检查。在 v2.1.242 之前,Claude Code 仍会启动会话。
2877 2922
2878```text theme={null}2923```text theme={null}
2879Error: Invalid --agents configuration:2924Error: Invalid --agents configuration:
2880<what failed>2925<what failed>
2881```2926```
2882 2927
2883第一行之后的内容取决于值如何失败。Claude Code 按顺序运行这些检查,并在第一个失败的检查处停止。如果您的值有两种问题,您只有在修复第一个问题后才会看到第二个问题:2928第一行之后的内容取决于该值失败的方式。Claude Code 按顺序执行以下检查,并在第一个失败的检查处停止。如果您的值存在两类问题,只有在修复第一类之后才会看到第二类:
2884 2929
28851. 当值以 `{` 开头但不能解析为 JSON,或 `--agents` 文件的内容不能解析时,Claude Code 会打印一行 `invalid JSON:`,其中包含 JSON 解析器自己的消息29301. 当值以 `{` 开头但无法解析为 JSON,或 `--agents` 文件的内容无法解析时,Claude Code 会打印一行 `invalid JSON:`,其中包含 JSON 解析器自身的消息
28862. 当它解析但代理定义与 [CLI 定义的子代理](/docs/zh-CN/sub-agents#choose-the-subagent-scope)的架构不匹配时,Claude Code 会为每个问题打印一行29312. 当值可以解析,但某个 Agent 定义与 [CLI 定义的子代理](/docs/zh-CN/sub-agents#choose-the-subagent-scope)的 schema 不匹配时,Claude Code 会为每个问题打印一行
28873. 当代理名称以 `-` 开头时,Claude Code 会打印 `<name>: agent names must not start with '-'`29323. 当 Agent 名称以 `-` 开头时,Claude Code 会打印 `<name>: agent names must not start with '-'`
2888 2933
2889当有超过 20 行问题时,Claude Code 会打印前 20 行,并用 `…and N more` 替换其余部分。2934当问题行超过 20 行时,Claude Code 会打印前 20 行,并将其余部分替换为 `…and N more`。
2890 2935
2891使用 `--print` 时,`--agents` 也接受 [JSON 文件的路径](/docs/zh-CN/sub-agents#choose-the-subagent-scope)代替内联对象。在 v2.1.281 之前,`--agents` 仅接受内联 JSON,并将文件路径视为无效 JSON。文件形式有其自己的拒绝,打印在此消息的位置,包括这些:2936使用 `--print` 时,`--agents` 还接受 [JSON 文件的路径](/docs/zh-CN/sub-agents#choose-the-subagent-scope)来代替内联对象。在 v2.1.281 之前,`--agents` 只接受内联 JSON,并将文件路径视为无效 JSON。文件形式有其自身的拒绝情况,会打印在此消息的位置,包括以下几种:
2892 2937
2893* **`Error: --agents takes a JSON object, or a file path only with --print (-p)`**:Claude Code 在交互会话中将值读取为文件路径。将定义作为内联 JSON 传递,或添加 `-p` 从文件读取它们。2938* **`Error: --agents takes a JSON object, or a file path only with --print (-p)`**:Claude Code 在交互式会话中将该值读取为文件路径。请以内联 JSON 形式传入定义,或添加 `-p` 以从文件中读取。
2894* **`Error: --agents file not found: <path>`**:该路径不存在任何文件。不以 `{` 开头且不是有效 JSON 的值被读取为路径,所以您的 shell 损坏的内联 JSON 也可能以这种方式失败。检查路径或引号,然后再次运行命令。2939* **`Error: --agents file not found: <path>`**:该路径下不存在文件。不以 `{` 开头且不是有效 JSON 的值会被读取为路径,因此被 shell 破坏的内联 JSON 也可能以这种方式失败。请检查路径或引号,然后重新运行命令。
2895 2940
2896**应该做什么:**2941**解决方法:**
2897 2942
2898* 修复消息列出的每个问题,然后再次运行命令。请参阅 [CLI 定义的子代理采用的字段](/docs/zh-CN/sub-agents#choose-the-subagent-scope)。2943* 修复消息列出的每个问题,然后重新运行命令。请参阅 [CLI 定义的子代理可接受的字段](/docs/zh-CN/sub-agents#choose-the-subagent-scope)。
2899 2944
2900<h3 id="cloud-sessions-cannot-be-created-from-a-restricted-session">2945<h3 id="cloud-sessions-cannot-be-created-from-a-restricted-session">
2901 无法从 `--restricted` 会话创建云会话2946 无法从 `--restricted` 会话创建云端会话
2902</h3>2947</h3>
2903 2948
2904当您使用 [`--restricted`](/docs/zh-CN/cli-reference#cli-flags) 启动会话时,Claude Code 拒绝从中创建[云会话](/docs/zh-CN/claude-code-on-the-web#from-terminal-to-cloud),因为新会话将在受限进程之外运行,不会强制执行受限模式。Claude Code 在客户端拒绝,在联系服务器之前,所以不会创建云会话:2949当您使用 [`--restricted`](/docs/zh-CN/cli-reference#cli-flags) 启动会话时,Claude Code 会拒绝从该会话创建[云端会话](/docs/zh-CN/claude-code-on-the-web#from-terminal-to-cloud),因为新会话将在受限进程之外运行,不会强制执行受限模式。Claude Code 在客户端、联系服务器之前就会拒绝,因此不会创建云端会话:
2905 2950
2906```text theme={null}2951```text theme={null}
2907Cloud sessions cannot be created from a --restricted session: they would not enforce it.2952Cloud sessions cannot be created from a --restricted session: they would not enforce it.
2908```2953```
2909 2954
2910**应该做什么:**2955**解决方法:**
2911 2956
2912* 在受限会话中本地运行任务2957* 在受限会话中本地运行该任务
2913* 如果您控制会话的启动方式,请启动一个没有 `--restricted` 的新 `claude` 会话,并从那里创建云会话2958* 如果您能控制会话的启动方式,请启动一个不带 `--restricted` 的新 `claude` 会话,并从那里创建云端会话
2914 2959
2915在 v2.1.248 之前,Claude Code 没有 `--restricted` 标志;较早的版本会以未知选项错误拒绝该标志本身。2960在 v2.1.248 之前,Claude Code 没有 `--restricted` 标志;较早的版本会以未知选项错误拒绝该标志本身。
2916 2961
2917<h3 id="cloud-sessions-are-disabled-by-your-organizations-policy">2962<h3 id="cloud-sessions-are-disabled-by-your-organizations-policy">
2918 您的组织的策略禁用了云会话2963 云端会话已被您组织的策略禁用
2919</h3>2964</h3>
2920 2965
2921您的组织的 `allow_remote_sessions` 策略已关闭,所以[云会话](/docs/zh-CN/claude-code-on-the-web)和使用它们的命令不可用:2966您组织的 `allow_remote_sessions` 策略处于关闭状态,因此[云端会话](/docs/zh-CN/claude-code-on-the-web)以及使用云端会话的命令不可用:
2922 2967
2923```text theme={null}2968```text theme={null}
2924Cloud sessions are disabled by your organization's policy. Contact your organization admin to enable them.2969Cloud sessions are disabled by your organization's policy. Contact your organization admin to enable them.
2925```2970```
2926 2971
2927当您[从终端创建云会话](/docs/zh-CN/claude-code-on-the-web#from-terminal-to-cloud)时,消息会出现,当您提交需要云会话的命令时,例如 `/teleport`、`/remote-env` 或 `/web-setup`。在 v2.1.268 之前,提交其中一个命令会返回[`Unknown command`](#unknown-command)。2972当您[从终端创建云端会话](/docs/zh-CN/claude-code-on-the-web#from-terminal-to-cloud)时,以及当您提交需要云端会话的命令(例如 `/teleport`、`/remote-env` 或 `/web-setup`)时,会出现此消息。在 v2.1.268 之前,提交这些命令之一会返回 [`Unknown command`](#unknown-command)。
2928 2973
2929这是一个服务器端组织策略,所以它不能从本地设置、环境变量或 CLI 标志中被覆盖。2974这是服务器端的组织策略,因此无法通过本地设置、环境变量或 CLI 标志覆盖。
2930 2975
2931如果 Claude Code 还没有加载您的组织策略或无法获取它,这些命令会回答 `Couldn't verify your organization's policy for cloud sessions. Check your network connection, then restart Claude Code and try again.`。2976如果 Claude Code 尚未加载您组织的策略或无法获取该策略,这些命令会改为回复 `Couldn't verify your organization's policy for cloud sessions. Check your network connection, then restart Claude Code and try again.`。
2932 2977
2933**应该做什么:**2978**解决方法:**
2934 2979
2935* 请您的组织中的[所有者](/docs/zh-CN/server-managed-settings#access-control)在 [claude.ai/admin-settings/claude-code](https://claude.ai/admin-settings/claude-code) 的 Claude Code 管理员设置中启用云会话2980* 请您组织中的 [Owner](/docs/zh-CN/server-managed-settings#access-control) 在 [claude.ai/admin-settings/claude-code](https://claude.ai/admin-settings/claude-code) 的 Claude Code 管理设置中启用云端会话
2936* 如果消息说它无法验证策略,请检查您的网络连接,然后重新启动 Claude Code 并重试2981* 如果消息显示无法验证策略,请检查网络连接,然后重启 Claude Code 并重试
2937 2982
2938<h3 id="the-json-schema-value-is-not-a-valid-json-schema">2983<h3 id="the-json-schema-value-is-not-a-valid-json-schema">
2939 `--json-schema` 值不是有效的 JSON Schema2984 `--json-schema` 的值不是有效的 JSON Schema
2940</h3>2985</h3>
2941 2986
2942您传递给 [`--json-schema`](/docs/zh-CN/cli-reference#cli-flags) 的架构在[非交互模式](/docs/zh-CN/headless#get-structured-output)中失败了 JSON Schema 编译,所以 `claude` 以代码 1 退出,而不是运行提示。在 v2.1.205 之前,无效的架构会产生无结构的输出,没有错误,任何使用 `format` 关键字的架构都被视为无效。2987您在[非交互模式](/docs/zh-CN/headless#get-structured-output)下传给 [`--json-schema`](/docs/zh-CN/cli-reference#cli-flags) 的 schema 未能通过 JSON Schema 编译,因此 `claude` 以退出码 1 退出,而不会运行提示词。在 v2.1.205 之前,无效的 schema 会在没有错误的情况下产生非结构化输出,并且任何使用 `format` 关键字的 schema 都会被视为无效。
2943 2988
2944```text theme={null}2989```text theme={null}
2945Error: --json-schema is not a valid JSON Schema: data/type must be equal to one of the allowed values2990Error: --json-schema is not a valid JSON Schema: data/type must be equal to one of the allowed values
2946```2991```
2947 2992
2948第二个冒号后的文本是验证器的诊断,并命名失败的关键字或位置。使用 `format` 关键字的架构,例如 `"format": "email"`,是有效的:Claude Code 接受 `format` 作为注释,不强制执行它。2993第二个冒号之后的文本是验证器的诊断信息,指出了失败的关键字或位置。使用 `format` 关键字的 schema(例如 `"format": "email"`)是有效的:Claude Code 将 `format` 作为注解接受,但不会强制执行它。
2949 2994
2950Claude Code 在架构编译之前运行两个检查:它拒绝不可解析的 JSON 值,显示 `Error: --json-schema is not valid JSON`,以及不是对象的有效 JSON,显示 `Error: --json-schema must be a JSON object`。2995Claude Code 在 schema 编译之前会执行两项检查:对于无法解析为 JSON 的值,它会以 `Error: --json-schema is not valid JSON` 拒绝;对于不是对象的有效 JSON,它会以 `Error: --json-schema must be a JSON object` 拒绝。
2951 2996
2952**应该做什么:**2997**解决方法:**
2953 2998
2954* 修复诊断命名的架构部分,然后重新运行命令2999* 修复诊断信息所指出的 schema 部分,然后重新运行命令
2955* 请参阅[获取结构化输出](/docs/zh-CN/headless#get-structured-output)以获取工作架构和命令3000* 请参阅[获取结构化输出](/docs/zh-CN/headless#get-structured-output),了解可用的 schema 和命令
2956 3001
2957<h3 id="settings-file-exceeds-the-2mib-limit">3002<h3 id="settings-file-exceeds-the-2mib-limit">
2958 设置文件超过 2MiB 限制3003 设置文件超过 2MiB 限制
2959</h3>3004</h3>
2960 3005
2961您传递给 [`--settings`](/docs/zh-CN/cli-reference#cli-flags) 的文件大于 2 MiB,所以 `claude` 在启动时以代码 1 退出,而不是加载它。在 v2.1.214 之前,Claude Code 读取文件时没有大小检查,多 GB 文件或诸如 `/dev/zero` 之类的设备文件会无限增长内存。3006您传给 [`--settings`](/docs/zh-CN/cli-reference#cli-flags) 的文件大于 2 MiB,因此 `claude` 在启动时以退出码 1 退出,而不会加载该文件。在 v2.1.214 之前,Claude Code 读取该文件时不做大小检查,数 GB 大小的文件或 `/dev/zero` 之类的设备文件会导致内存无限增长。
2962 3007
2963```text theme={null}3008```text theme={null}
2964Error: Settings file exceeds the 2MiB limit: /path/to/settings.json3009Error: Settings file exceeds the 2MiB limit: /path/to/settings.json
2965```3010```
2966 3011
2967Claude Code 以相同的方式拒绝不是常规文件的 `--settings` 路径:设备、FIFO 或套接字报告 `Error: Cannot use settings file (Not a regular file (device, FIFO, or socket))`,后跟路径,目录报告 `EISDIR` 原因。3012对于不是常规文件的 `--settings` 路径,Claude Code 也会以同样的方式拒绝:设备、FIFO 或套接字会报告 `Error: Cannot use settings file (Not a regular file (device, FIFO, or socket))` 并附上路径,目录则会报告 `EISDIR` 原因。
2968 3013
2969**应该做什么:**3014**解决方法:**
2970 3015
2971* 将 `--settings` 指向 2 MiB 以下的常规 JSON 设置文件。请参阅[设置](/docs/zh-CN/settings)了解格式。3016* 将 `--settings` 指向一个小于 2 MiB 的常规 JSON 设置文件。有关格式,请参阅[设置](/docs/zh-CN/settings)。
2972 3017
2973<h3 id="the-current-directory-no-longer-exists">3018<h3 id="the-current-directory-no-longer-exists">
2974 当前目录不再存在3019 当前目录已不存在
2975</h3>3020</h3>
2976 3021
2977您从一个在您的 shell 进入后被删除或移动的目录启动了 `claude`,例如另一个 shell 删除的 worktree 或临时目录。Claude Code 无法读取其工作目录,所以它在启动会话之前以代码 1 退出,在交互和[非交互](/docs/zh-CN/headless)模式中都是如此。在 v2.1.239 之前,Claude Code 会因缩小的捆绑源和原始 `ENOENT ... uv_cwd` 堆栈在 stderr 上崩溃,而不是显示此消息。3022您从一个在 shell 进入后已被删除或移动的目录启动了 `claude`,例如被另一个 shell 删除的 worktree 或临时目录。Claude Code 无法读取其工作目录,因此在启动会话之前以退出码 1 退出,交互模式和[非交互](/docs/zh-CN/headless)模式均是如此。在 v2.1.239 之前,Claude Code 会崩溃,并在 stderr 上输出压缩后的打包源代码和原始的 `ENOENT ... uv_cwd` 堆栈,而不是显示此消息。
2978 3023
2979```text theme={null}3024```text theme={null}
2980The current directory no longer exists (it was deleted or moved). Start Claude Code from an existing directory.3025The current directory no longer exists (it was deleted or moved). Start Claude Code from an existing directory.
2981error: The current working directory was deleted, so that command didn't work. Please cd into a different directory and try again.3026error: The current working directory was deleted, so that command didn't work. Please cd into a different directory and try again.
2982```3027```
2983 3028
2984两种形式的原因和修复是相同的。3029这两种形式的原因和修复方法相同。
2985 3030
2986当 Claude Code 因其他原因(例如权限更改)无法读取工作目录时,消息会命名错误代码:`Can't read the current directory (EACCES). Start Claude Code from a different directory.`3031当 Claude Code 因其他原因(例如权限变更)无法读取工作目录时,消息会改为指出错误代码:`Can't read the current directory (EACCES). Start Claude Code from a different directory.`
2987 3032
2988在 macOS 上,`~/Desktop`、`~/Documents`、`~/Downloads` 或 iCloud Drive 中目录的 `EPERM` 通常意味着 macOS 阻止您的终端应用访问该文件夹。读取该文件夹的其他命令也会以相同的方式失败:即使使用 `sudo`,`ls` 也会报告 `Operation not permitted`。3033在 macOS 上,对于 `~/Desktop`、`~/Documents`、`~/Downloads` 或 iCloud Drive 中目录出现的 `EPERM`,通常意味着 macOS 阻止了您的终端应用访问该文件夹。读取该文件夹的其他命令也会以同样方式失败:在那里运行 `ls` 会报告 `Operation not permitted`,即使使用 `sudo` 也是如此。
2989 3034
2990**应该做什么:**3035**解决方法:**
2991 3036
2992* 更改为存在的目录,例如您的主目录或项目目录,然后再次运行 `claude`3037* 切换到一个存在的目录,例如您的主目录或项目目录,然后再次运行 `claude`
2993* 如果目录在同一路径被重新创建,您的 shell 仍然持有已删除的目录。运行 `cd "$PWD"` 或离开并重新进入目录,然后再次运行 `claude`3038* 如果该目录已在相同路径下重新创建,您的 shell 仍持有已删除的那个目录。请运行 `cd "$PWD"` 或离开后重新进入该目录,然后再次运行 `claude`
2994* 对于 macOS 上的 `EPERM`,使用 Cmd+Q 退出您的终端应用,重新打开它,返回该文件夹,然后运行 `claude`。如果该文件夹中的 `ls` 仍然失败,请打开**系统设置 > 隐私和安全 > 文件和文件夹**,为您的终端应用打开该文件夹,然后重新打开终端3039* 对于 macOS 上的 `EPERM`,请使用 Cmd+Q 退出终端应用,重新打开,返回该文件夹并运行 `claude`。如果在该文件夹中 `ls` 仍然失败,请打开 **System Settings > Privacy & Security > Files and Folders**,为您的终端应用启用该文件夹,然后重新打开终端
2995 3040
2996<h3 id="temp-directory-refused-or-cannot-be-created">3041<h3 id="temp-directory-refused-or-cannot-be-created">
2997 临时目录被拒绝或无法创建3042 临时目录被拒绝或无法创建
2998</h3>3043</h3>
2999 3044
3000在 macOS 和 Linux 上,Claude Code 在启动时创建一个私有临时目录 `claude-<uid>`,位于系统临时目录或 [`CLAUDE_CODE_TMPDIR`](/docs/zh-CN/env-vars) 覆盖下。当目录无法创建,或该路径处的现有条目未通过安全检查时,Claude Code 将失败打印到 stderr 并以代码 1 退出,而不是启动会话:3045在 macOS 和 Linux 上,Claude Code 在启动时会在系统临时目录或 [`CLAUDE_CODE_TMPDIR`](/docs/zh-CN/env-vars) 覆盖的位置下创建一个私有临时目录 `claude-<uid>`。当该目录无法创建,或该路径下已存在的条目未通过安全检查时,Claude Code 会将失败信息打印到 stderr 并以退出码 1 退出,而不会启动会话:
3001 3046
3002```text wrap theme={null}3047```text wrap theme={null}
3003ENOSPC: no space left on device, mkdir '/tmp/claude-501'3048ENOSPC: no space left on device, mkdir '/tmp/claude-501'
3009Temp directory /tmp/claude-501 is not readable (its mode may have been altered, or a path component denies search). Refusing to use it — restore its permissions (chmod 0700) or remove it. Set CLAUDE_CODE_TMPDIR to a directory you control, or ask an administrator to remove it.3054Temp directory /tmp/claude-501 is not readable (its mode may have been altered, or a path component denies search). Refusing to use it — restore its permissions (chmod 0700) or remove it. Set CLAUDE_CODE_TMPDIR to a directory you control, or ask an administrator to remove it.
3010```3055```
3011 3056
3012**应该做什么:**3057**解决方法:**
3013 3058
3014* 对于 `ENOSPC`,释放保存临时目录的卷上的磁盘空间3059* 对于 `ENOSPC`,请释放临时目录所在卷的磁盘空间
3015* 对于 `Refusing to use it` 形式,删除命名的条目本身,而不是链接指向的内容,然后再次启动 Claude Code;对于 `owned by uid` 形式,只有管理员或该用户可以删除它3060* 对于 `Refusing to use it` 形式,请删除所指出的条目本身(而不是链接指向的目标),然后再次启动 Claude Code;对于 `owned by uid` 形式,只有管理员或该用户才能删除它
3016* 对于 `is not readable`,在命名目录上运行 `chmod 0700`,或删除它并重新启动3061* 对于 `is not readable`,请对所指出的目录运行 `chmod 0700`,或将其删除后重新启动
3017* 在任何这些情况下,将 [`CLAUDE_CODE_TMPDIR`](/docs/zh-CN/env-vars) 设置为您控制的目录并启动 Claude Code,保留被拒绝的路径不变3062* 在上述任何情况下,都可以将 [`CLAUDE_CODE_TMPDIR`](/docs/zh-CN/env-vars) 设置为您控制的目录,然后再次启动 Claude Code,而不去处理被拒绝的路径
3018 3063
3019<h3 id="directory-couldnt-be-resolved-to-a-real-location">3064<h3 id="directory-couldnt-be-resolved-to-a-real-location">
3020 目录无法解析为真实位置3065 目录无法解析为真实位置
3021</h3>3066</h3>
3022 3067
3023您为工作目录的子目录运行了 `/add-dir`,Claude Code 无法将目录解析为其真实位置。3068您对工作目录的某个子目录运行了 `/add-dir`,而 Claude Code 无法将该目录解析为其真实位置。
3024 3069
3025您已经可以访问工作目录的子目录,所以 `/add-dir` 只加载其 skills、命令和代理。在加载它们之前,Claude Code 检查目录的真实位置(解析任何符号链接)是否在工作目录内。当 Claude Code 无法解析该位置时,它不加载任何内容并显示此消息:3070您已经拥有工作目录子目录的文件访问权限,因此 `/add-dir` 只会加载其中的 skill、命令和 Agent。在加载之前,Claude Code 会检查该目录的真实位置(解析所有符号链接后)是否位于工作目录内。当 Claude Code 无法解析该位置时,它不会加载任何内容,并显示以下消息:
3026 3071
3027```text theme={null}3072```text theme={null}
3028packages/app couldn't be resolved to a real location, so its skills, commands, and agents weren't loaded. Check that it is a directory inside the working directory and try again.3073packages/app couldn't be resolved to a real location, so its skills, commands, and agents weren't loaded. Check that it is a directory inside the working directory and try again.
3029```3074```
3030 3075
3031**应该做什么:**3076**解决方法:**
3032 3077
3033* 检查路径是否命名工作目录内的真实目录,然后再次运行 `/add-dir`3078* 检查该路径是否指向工作目录内的真实目录,然后再次运行 `/add-dir`
3034* 消息不会改变您的文件访问权限;它只报告目录的 `.claude/` 内容未被加载3079* 此消息不会改变您的文件访问权限;它只是报告该目录的 `.claude/` 内容未被加载
3035 3080
3036在 v2.1.261 之前,当工作目录在 `/net/<host>` 自动挂载上时,此消息也会为每个 `/add-dir <subdirectory>` 出现,Claude Code 按设计拒绝解析路径;目录很好,重试无法帮助。3081在 v2.1.261 之前,当工作目录位于 `/net/<host>` 自动挂载点上时,每次执行 `/add-dir <subdirectory>` 也会出现此消息,因为 Claude Code 按设计不会解析这类路径;目录本身没有问题,重试也无济于事。
3037 3082
3038<h3 id="workspace-not-trusted-when-starting-remote-control">3083<h3 id="workspace-not-trusted-when-starting-remote-control">
3039 启动远程控制时工作区不受信任3084 启动 Remote Control 时工作区不受信任
3040</h3>3085</h3>
3041 3086
3042您在未信任的目录中使用 `claude remote-control` 或其 `claude rc` 别名启动了[远程控制](/docs/zh-CN/remote-control)服务器模式,命令无法询问您是否信任它。例如,命令的标准输入或标准输出不是终端,因为其中一个被重定向或管道化。命令以代码 1 退出:3087您在尚未信任的目录中使用 `claude remote-control` 或其别名 `claude rc` 启动了 [Remote Control](/docs/zh-CN/remote-control) 服务器模式,而该命令无法询问您是否信任该目录。例如,命令的标准输入或标准输出不是终端,因为其中之一被重定向或通过管道传输。该命令以退出码 1 退出:
3043 3088
3044```text theme={null}3089```text theme={null}
3045Error: Workspace not trusted. Please run `claude` in /Users/you/project first to review and accept the workspace trust dialog.3090Error: Workspace not trusted. Please run `claude` in /Users/you/project first to review and accept the workspace trust dialog.
3046```3091```
3047 3092
3048两个也以 `Error: Workspace not trusted.` 开头的变体也出现在足够小的终端中,无法显示信任目录会打开什么,或一个没有报告其大小的终端。放大窗口或切换到正常终端窗口,然后再次运行 `claude rc`。3093另外两种同样以 `Error: Workspace not trusted.` 开头的变体会出现在以下终端中:终端太小,无法显示信任该目录会启用的内容,或者终端未报告其尺寸。请放大窗口或切换到普通终端窗口,然后再次运行 `claude rc`。
3049 3094
3050在您的主目录中,消息是不同的,因为工作区信任对话永远不会为主目录保存信任,所以在那里接受它无法满足此检查。在 v2.1.214 之前,主目录显示上面的消息,其建议在那里无法成功。3095在您的主目录中,消息会有所不同,因为工作区信任对话框永远不会为主目录保存信任,所以在主目录中接受信任无法满足此检查。在 v2.1.214 之前,主目录会显示上述消息,而其中的建议在主目录中无法奏效。
3051 3096
3052```text theme={null}3097```text theme={null}
3053Error: Workspace not trusted. /Users/you is your home directory, and for security home-directory trust is never saved, so running `claude` here first won't help. Run `claude rc` from a project directory instead (run `claude` there once to accept the trust dialog).3098Error: Workspace not trusted. /Users/you is your home directory, and for security home-directory trust is never saved, so running `claude` here first won't help. Run `claude rc` from a project directory instead (run `claude` there once to accept the trust dialog).
3054```3099```
3055 3100
3056如果您在 [`Trust <directory>?` 问题](/docs/zh-CN/remote-control#requirements)处回答 `n` 或按 Enter,命令会打印一条 `Remote Control did not start` 消息,命名目录并以代码 1 退出。再次运行 `claude rc` 以回答 `y`。3101如果您在 [`Trust <directory>?` 问题](/docs/zh-CN/remote-control#requirements)处回答 `n` 或按 Enter,该命令会打印一条指出该目录的 `Remote Control did not start` 消息,并以退出码 1 退出。再次运行 `claude rc` 并回答 `y` 即可。
3057 3102
3058**应该做什么:**3103**解决方法:**
3059 3104
3060* 首先从终端信任目录:在那里运行 `claude rc` 并回答 `y`,或运行 `claude` 并接受[工作区信任对话](/docs/zh-CN/permissions#project-allow-rules-and-workspace-trust),然后再次运行您的原始命令3105* 先从终端信任该目录:在该目录中运行 `claude rc` 并回答 `y`,或在该目录中运行 `claude` 并接受[工作区信任对话框](/docs/zh-CN/permissions#project-allow-rules-and-workspace-trust),然后再次运行原来的命令
3061* 在您的主目录中,更改为项目目录并在那里启动远程控制3106* 如果在主目录中,请切换到项目目录并在那里启动 Remote Control
3062 3107
3063在 v2.1.284 之前,命令从不询问,即使在终端中也是如此。3108在 v2.1.284 之前,即使在终端中,该命令也从不询问。
3064 3109
3065<h3 id="not-carried-over-to-the-sessions-remote-control-starts">3110<h3 id="not-carried-over-to-the-sessions-remote-control-starts">
3066 未被远程控制启动的会话继承3111 不会传递到 Remote Control 启动的会话
3067</h3>3112</h3>
3068 3113
3069您使用全局 `claude` 标志在 `remote-control` 动词之前启动了[远程控制](/docs/zh-CN/remote-control),该标志会限制或配置远程控制启动的会话,例如 `--settings`、`--setting-sources`、`--permission-mode`、`--disallowed-tools` 或 `--mcp-config`。放在动词之前的标志永远不会到达这些会话。Claude Code 拒绝启动,命名标志:3114您在 `remote-control` 动词之前使用了一个全局 `claude` 标志来启动 [Remote Control](/docs/zh-CN/remote-control),该标志会限制或配置 Remote Control 启动的会话,例如 `--settings`、`--setting-sources`、`--permission-mode`、`--disallowed-tools` 或 `--mcp-config`。放在动词之前的标志永远不会到达这些会话。Claude Code 会拒绝启动,并指出该标志:
3070 3115
3071```text theme={null}3116```text theme={null}
3072Error: `--settings` before `remote-control` is not carried over to the sessions Remote Control starts, so Remote Control refuses to start rather than drop it — remove it, and give Remote Control's own options after the verb (see `claude remote-control --help`).3117Error: `--settings` before `remote-control` is not carried over to the sessions Remote Control starts, so Remote Control refuses to start rather than drop it — remove it, and give Remote Control's own options after the verb (see `claude remote-control --help`).
3073```3118```
3074 3119
3075Claude Code 不拒绝无害的全局标志,例如 `--verbose`、`--model` 或包装器注入的 `--session-id` 或 `--plugin-dir`:它忽略它们,远程控制启动。3120对于丢弃后无害的全局标志,例如 `--verbose`、`--model`,或由包装器注入的 `--session-id` 或 `--plugin-dir`,Claude Code 不会拒绝:它会忽略这些标志,Remote Control 照常启动。
3076 3121
3077Claude Code 也拒绝启动一个它还不认识为无害的全局标志,所以较新版本中添加的标志可能会出现在此消息中,直到稍后的版本将其标记为无害。3122对于尚未被识别为无害的全局标志,Claude Code 也会拒绝启动,因此在较新版本中新增的标志可能会出现在此消息中,直到后续版本将其标记为无害。
3078 3123
3079**应该做什么:**3124**解决方法:**
3080 3125
3081* 从动词之前删除标志,并在其后传递[远程控制自己的选项](/docs/zh-CN/remote-control#start-a-remote-control-session);`claude remote-control --help` 列出它们3126* 移除动词之前的标志,并在动词之后传入 [Remote Control 自身的选项](/docs/zh-CN/remote-control#start-a-remote-control-session);`claude remote-control --help` 会列出这些选项
3082* 当被拒绝的标志是 `--permission-mode` 时,运行 `claude remote-control --permission-mode <mode>` 为远程控制启动的会话设置权限模式3127* 当被拒绝的标志是 `--permission-mode` 时,请运行 `claude remote-control --permission-mode <mode>` 来设置 Remote Control 启动的会话的权限模式
3083 3128
3084在 v2.1.248 之前,当全局标志首先出现时,`claude remote-control` 不接受其自己的标志,命令失败并显示未知选项错误。3129在 v2.1.248 之前,当全局标志位于前面时,`claude remote-control` 不接受其自身的标志,命令会以 `unknown option` 错误失败。
3085 3130
3086<h3 id="claude-import-is-not-yet-available-in-this-build">3131<h3 id="claude-import-is-not-yet-available-in-this-build">
3087 claude import 在此构建中尚不可用3132 此构建版本中尚不可用 claude import
3088</h3>3133</h3>
3089 3134
3090您运行了 [`claude import`](/docs/zh-CN/cli-reference#cli-commands),Claude Code 发现导入流已关闭,所以命令以代码 1 退出,而不是启动导入。在 v2.1.222 之前,关闭导入流的构建将 `import` 视为提示并启动交互会话,而不是打印此消息。3135您运行了 [`claude import`](/docs/zh-CN/cli-reference#cli-commands),而 Claude Code 发现导入流程处于关闭状态,因此该命令以退出码 1 退出,而不会开始导入。在 v2.1.222 之前,关闭了导入流程的构建版本会将 `import` 视为提示词并启动交互式会话,而不是打印此消息。
3091 3136
3092```text theme={null}3137```text theme={null}
3093`claude import` is not yet available in this build. Run `claude` and use /mcp or edit ~/.claude/settings.json directly.3138`claude import` is not yet available in this build. Run `claude` and use /mcp or edit ~/.claude/settings.json directly.
3094```3139```
3095 3140
3096Claude Code 通过从 Anthropic 获取并在磁盘上缓存的功能标志打开 `claude import`。此消息意味着缓存的值已关闭。原因通常是以下之一:3141Claude Code 通过从 Anthropic 获取并缓存到磁盘上的功能标志来启用 `claude import`。此消息表示缓存的值为关闭。原因通常是以下之一:
3097 3142
3098* 您自安装以来还没有启动会话,所以 Claude Code 还没有获取标志。第一个 `claude import` 即使功能对您可用,也可能打印此消息。3143* 安装后您尚未启动过会话,因此 Claude Code 还没有获取该标志。即使该功能对您可用,第一次运行 `claude import` 也可能打印此消息。
3099* 您通过 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或 AWS 上的 Claude Platform,或通过[Claude 应用网关](/docs/zh-CN/claude-apps-gateway#availability-and-limitations)使用 Claude Code。Claude Code 在这些会话中不获取功能标志,所以 `claude import` 保持不可用。3144* 您通过 Amazon Bedrock、Google Cloud's Agent Platform、Microsoft Foundry 或 Claude Platform on AWS 使用 Claude Code,或者通过 [Claude apps gateway](/docs/zh-CN/claude-apps-gateway#availability-and-limitations) 使用。Claude Code 在这些会话中不会获取功能标志,因此 `claude import` 保持不可用。
3100* 您设置了 `DISABLE_TELEMETRY`、`DO_NOT_TRACK`、`DISABLE_GROWTHBOOK` 或 [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](/docs/zh-CN/env-vars),它们关闭功能标志获取,所以 `claude import` 保持不可用。3145* 您设置了 `DISABLE_TELEMETRY`、`DO_NOT_TRACK`、`DISABLE_GROWTHBOOK` 或 [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](/docs/zh-CN/env-vars),这些设置会关闭功能标志的获取,因此 `claude import` 保持不可用。
3101 3146
3102**应该做什么:**3147**解决方法:**
3103 3148
3104* 在新安装上,启动 `claude`,等待会话加载,退出,然后再次运行 `claude import`3149* 在全新安装中,启动 `claude`,等待会话加载完成后退出,然后再次运行 `claude import`
3105* 在功能标志获取保持关闭的地方,自己设置配置:使用 [`claude mcp add`](/docs/zh-CN/mcp#installing-mcp-servers) 添加 MCP 服务器,并创建您想要继承的 [`CLAUDE.md` 文件](/docs/zh-CN/memory#how-claude-md-files-load)、[skills 和命令](/docs/zh-CN/skills#where-skills-live)以及[子代理](/docs/zh-CN/sub-agents#choose-the-subagent-scope)。消息也命名 `~/.claude/settings.json`。在 `claude import` 继承的配置中,该文件仅保存[权限模式](/docs/zh-CN/settings-reference#permission-settings);Claude Code 不从中读取 MCP 服务器。3150* 在功能标志获取保持关闭的情况下,请自行完成配置:使用 [`claude mcp add`](/docs/zh-CN/mcp#installing-mcp-servers) 添加 MCP 服务器,并创建您想要迁移的 [`CLAUDE.md` 文件](/docs/zh-CN/memory#how-claude-md-files-load)、[skill 和命令](/docs/zh-CN/skills#where-skills-live)以及[子代理](/docs/zh-CN/sub-agents#choose-the-subagent-scope)。消息中还提到了 `~/.claude/settings.json`。在 `claude import` 所迁移的配置中,该文件只保存[权限模式](/docs/zh-CN/settings-reference#permission-settings);Claude Code 不会从中读取 MCP 服务器。
3106 3151
3107<h3 id="could-not-read-claude-code-config">3152<h3 id="could-not-read-claude-code-config">
3108 无法读取 Claude Code 配置3153 无法读取 Claude Code 配置
3109</h3>3154</h3>
3110 3155
3111您在 Claude Code 无法解析 `~/.claude.json` 时运行了 [`claude import`](/docs/zh-CN/cli-reference#cli-commands),这是它存储您的登录和每个项目状态的文件。子命令读取该文件以检查可用性,但不显示交互会话显示的恢复对话,所以它以代码 1 退出。在 v2.1.222 之前,`claude import` 使用不可读的配置文件启动交互会话,其恢复对话处理该文件。3156您运行了 [`claude import`](/docs/zh-CN/cli-reference#cli-commands),而 Claude Code 无法解析 `~/.claude.json`,即它存储您的登录信息和各项目状态的文件。该子命令会读取该文件以检查可用性,但不会显示交互式会话所显示的恢复对话框,因此以退出码 1 退出。在 v2.1.222 之前,在配置文件无法读取的情况下运行 `claude import` 会启动交互式会话,由其恢复对话框处理该文件。
3112 3157
3113```text theme={null}3158```text theme={null}
3114Could not read Claude Code config — run `claude` with no arguments to recover it.3159Could not read Claude Code config — run `claude` with no arguments to recover it.
3115```3160```
3116 3161
3117**应该做什么:**3162**解决方法:**
3118 3163
3119* 运行不带参数的 `claude`。Claude Code 检测无效文件并提供重置它。然后再次运行 `claude import`。3164* 不带参数运行 `claude`。Claude Code 会检测到无效文件并提供重置选项。然后再次运行 `claude import`。
3120* 要保留您所做的手动编辑,请在编辑器中修复 `~/.claude.json` 中的 JSON 语法,然后重新运行 `claude import`3165* 若要保留您手动所做的编辑,请改为在编辑器中修复 `~/.claude.json` 中的 JSON 语法,然后重新运行 `claude import`
3121 3166
3122<h3 id="could-not-import-a-server-from-claude-desktop">3167<h3 id="could-not-import-a-server-from-claude-desktop">
3123 无法从 Claude Desktop 导入服务器3168 无法从 Claude Desktop 导入服务器
3124</h3>3169</h3>
3125 3170
3126Claude Code 无法添加您在 `claude mcp add-from-claude-desktop` 中选择的其中一个服务器。命令仍然导入其他选定的服务器,并为每个无法添加的服务器打印一行。在 v2.1.205 之前,第一个失败的服务器停止了导入。3171Claude Code 无法添加您在 `claude mcp add-from-claude-desktop` 中选择的某个服务器。该命令仍会导入其他选中的服务器,并为每个无法添加的服务器打印一行。在 v2.1.205 之前,第一个失败的服务器会中止整个导入。
3127 3172
3128```text theme={null}3173```text theme={null}
3129Could not import my server: Invalid name my server. Names can only contain letters, numbers, hyphens, and underscores.3174Could not import my server: Invalid name my server. Names can only contain letters, numbers, hyphens, and underscores.
3130```3175```
3131 3176
3132服务器名称后的文本是原因。最常见的是名称检查:Claude Desktop 允许服务器名称中的字符,例如空格和句号,而 `claude mcp` 限制为字母、数字、连字符和下划线。其他原因包括失败验证的服务器配置和被您的组织的 [MCP 策略](/docs/zh-CN/managed-mcp)阻止的服务器。3177服务器名称之后的文本是原因。最常见的是名称检查:Claude Desktop 允许服务器名称中包含空格和句点等字符,而 `claude mcp` 将其限制为字母、数字、连字符和下划线。其他原因包括服务器配置未通过验证,以及服务器被您组织的 [MCP 策略](/docs/zh-CN/managed-mcp)阻止。
3133 3178
3134**应该做什么:**3179**解决方法:**
3135 3180
3136* 在 `claude_desktop_config.json` 中重命名服务器以仅使用字母、数字、连字符和下划线,然后再次运行 `claude mcp add-from-claude-desktop`3181* 在 `claude_desktop_config.json` 中将服务器重命名为仅包含字母、数字、连字符和下划线的名称,然后再次运行 `claude mcp add-from-claude-desktop`
3137* 使用 `claude mcp add` 或 `claude mcp add-json` 在有效名称下直接添加该服务器。请参阅[从 Claude Desktop 导入 MCP 服务器](/docs/zh-CN/mcp#import-mcp-servers-from-claude-desktop)。3182* 使用有效名称通过 `claude mcp add` 或 `claude mcp add-json` 直接添加该服务器。请参阅[从 Claude Desktop 导入 MCP 服务器](/docs/zh-CN/mcp#import-mcp-servers-from-claude-desktop)。
3138 3183
3139<h3 id="cannot-add-mcp-server-to-the-managed-scope">3184<h3 id="cannot-add-mcp-server-to-the-managed-scope">
3140 无法将 MCP 服务器添加到托管范围3185 无法将 MCP 服务器添加到 managed 作用域
3141</h3>3186</h3>
3142 3187
3143您使用 `--scope managed` 运行了 `claude mcp add` 或 `claude mcp add-json`。该范围保存您的组织通过 [`managedMcpServers`](/docs/zh-CN/settings-reference#managedmcpservers) 托管设置提供的服务器。Claude Code 仅从托管设置读取它们,所以命令无法向该范围写入服务器。3188您使用 `--scope managed` 运行了 `claude mcp add` 或 `claude mcp add-json`。该作用域保存的是您的组织通过 [`managedMcpServers`](/docs/zh-CN/settings-reference#managedmcpservers) 托管设置提供的服务器。Claude Code 只从托管设置中读取这些服务器,因此该命令无法将服务器写入该作用域。
3144 3189
3145```text theme={null}3190```text theme={null}
3146Cannot add MCP server to scope: managed3191Cannot add MCP server to scope: managed
3147```3192```
3148 3193
3149**应该做什么:**3194**解决方法:**
3195
3196* 将服务器添加到您可以写入的作用域:`local`、`user` 或 `project`。不带 `--scope` 时,该命令使用 `local`。请参阅 [MCP 安装作用域](/docs/zh-CN/mcp#mcp-installation-scopes)
3197* 若要将服务器提供给组织中的每个用户,请将其添加到您部署的托管设置中的 [`managedMcpServers`](/docs/zh-CN/settings-reference#managedmcpservers)
3198
3199<h3 id="cannot-add-mcp-server-when-managed-settings-allow-only-plugin-servers">
3200 托管设置仅允许插件服务器时无法添加 MCP 服务器
3201</h3>
3202
3203您运行了 `claude mcp add` 或 `claude mcp add-json`,而您组织的托管设置将 [`strictPluginOnlyCustomization`](/docs/zh-CN/settings-reference#strictpluginonlycustomization) 设置为 `true` 或包含 `mcp` 的列表。在该设置下,Claude Code 不会从 `~/.claude.json` 或 `.mcp.json` 加载 MCP 服务器,因此该命令以退出码 1 退出,而不会保存一个永远不会加载的服务器:
3204
3205```text theme={null}
3206Cannot add MCP server: your organization's managed settings allow only MCP servers that plugins provide. Install a plugin that provides this server, or ask your administrator to make it available.
3207```
3208
3209`claude mcp add-from-claude-desktop` 会将您选择的每个服务器报告为未导入,原因即为此消息。[`/import`](/docs/zh-CN/commands#all-commands) 会针对它尝试添加的每个 MCP 服务器报告此消息,但仍会导入它找到的其他项目。
3210
3211在 v2.1.284 之前,这些命令会保存服务器并报告成功,但服务器永远不会加载。
3212
3213**解决方法:**
3150 3214
3151* 将服务器添加到您可以写入的范围:`local`、`user` 或 `project`。不带 `--scope` 时,命令使用 `local`。请参阅 [MCP 安装范围](/docs/zh-CN/mcp#mcp-installation-scopes)3215* 安装提供该服务器的[插件](/docs/zh-CN/plugins/install)
3152* 要为您的组织中的每个用户提供服务器,请将其添加到您部署的托管设置中的 [`managedMcpServers`](/docs/zh-CN/settings-reference#managedmcpservers)3216* 请管理员通过[插件](/docs/zh-CN/plugins/org)分发该服务器,或者如果它是远程 HTTP 或 SSE 服务器,则通过 [`managedMcpServers`](/docs/zh-CN/settings-reference#managedmcpservers) 提供它
3153 3217
3154<h3 id="cant-read-mcp-json">3218<h3 id="cant-read-mcp-json">
3155 无法读取 .mcp.json3219 无法读取 .mcp.json
3156</h3>3220</h3>
3157 3221
3158读取项目的 [`.mcp.json`](/docs/zh-CN/mcp#project-scope) 的命令,例如 `claude mcp add` 或 `claude mcp add-json` 使用 `--scope project`,或 `claude mcp remove`,发现您当前目录中的文件不是常规文件或大于 2 MiB,所以它以此错误退出,而不是读取文件。3222读取项目 [`.mcp.json`](/docs/zh-CN/mcp#project-scope) 的命令(例如带 `--scope project` 的 `claude mcp add` 或 `claude mcp add-json`,或 `claude mcp remove`)发现当前目录中的该文件不是常规文件或大于 2 MiB,因此以此错误退出,而不会读取该文件。
3159 3223
3160```text theme={null}3224```text theme={null}
3161Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes. Fix or remove it, then run the command again.3225Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes. Fix or remove it, then run the command again.
3162```3226```
3163 3227
3164在 v2.1.257 之前,`.mcp.json` 处的 FIFO 使命令永远等待,没有输出,指向诸如 `/dev/zero` 之类的设备文件的符号链接会增长内存,直到进程被杀死。3228在 v2.1.257 之前,位于 `.mcp.json` 的 FIFO 会使命令无限等待且没有任何输出,而指向 `/dev/zero` 之类设备文件的符号链接会使内存不断增长,直到进程被终止。
3165 3229
3166**应该做什么:**3230**解决方法:**
3167 3231
3168* 检查您当前目录中 `.mcp.json` 处的内容。将其替换为 [project-scope 格式](/docs/zh-CN/mcp#project-scope)中的普通 JSON 文件,或删除它,然后再次运行命令。3232* 检查当前目录中 `.mcp.json` 是什么。将其替换为采用[项目作用域格式](/docs/zh-CN/mcp#project-scope)的普通 JSON 文件,或将其删除,然后再次运行命令。
3169 3233
3170<h3 id="mcp-server-was-not-saved-or-removed">3234<h3 id="mcp-server-was-not-saved-or-removed">
3171 MCP 服务器未被保存或删除3235 MCP 服务器未被保存或移除
3172</h3>3236</h3>
3173 3237
3174您为 `user` 或 `local` [范围](/docs/zh-CN/mcp#mcp-installation-scopes)中的服务器运行了 `claude mcp add`、`claude mcp add-json` 或 `claude mcp remove`。两个范围都存储在 `~/.claude.json` 中,当 Claude Code 在写入后读取该文件时,更改不在该文件中。命令以此错误退出,而不是其成功行。3238您针对 `user` 或 `local` [作用域](/docs/zh-CN/mcp#mcp-installation-scopes)中的服务器运行了 `claude mcp add`、`claude mcp add-json` 或 `claude mcp remove`。这两个作用域都存储在 `~/.claude.json` 中,而 Claude Code 在写入后重新读取该文件时,发现其中没有该更改。该命令以此错误退出,而不是输出成功信息。
3175 3239
3176```text theme={null}3240```text theme={null}
3177MCP server "example" was not saved to /home/user/.claude.json. If that file is read-only or protected by a sandbox, make it writable or run the command outside the sandbox, then add the server again.3241MCP server "example" was not saved to /home/user/.claude.json. If that file is read-only or protected by a sandbox, make it writable or run the command outside the sandbox, then add the server again.
3178```3242```
3179 3243
3180删除后,消息读取 `was not removed from` 并以 `then remove the server again` 结尾。对于 `local` 范围服务器,路径后跟项目目录条目所属的,如 `(local scope for /path/to/project)`。3244执行移除操作后,消息会显示为 `was not removed from`,并以 `then remove the server again` 结尾。对于 `local` 作用域的服务器,路径后会附上该条目所属的项目目录,形式为 `(local scope for /path/to/project)`。
3181 3245
3182在 v2.1.283 之前,`claude mcp add`、`claude mcp add-json` 和 `claude mcp remove` 即使更改没有到达文件也报告成功。3246在 v2.1.283 之前,即使更改未写入文件,`claude mcp add`、`claude mcp add-json` 和 `claude mcp remove` 也会报告成功。
3183 3247
3184**应该做什么:**3248**解决方法:**
3185 3249
3186* 使消息命名的文件可写,或在沙箱外运行命令,然后再次运行相同的添加或删除命令。3250* 使消息中指出的文件可写,或在沙箱之外运行命令,然后再次运行相同的添加或移除命令。
3187 3251
3188<h3 id="mcp-server-may-not-have-been-saved-or-removed">3252<h3 id="mcp-server-may-not-have-been-saved-or-removed">
3189 MCP 服务器可能未被保存或删除3253 MCP 服务器可能未被保存或移除
3190</h3>3254</h3>
3191 3255
3192您为 `user` 或 `local` [范围](/docs/zh-CN/mcp#mcp-installation-scopes)中的服务器运行了 `claude mcp add`、`claude mcp add-json` 或 `claude mcp remove`,Claude Code 无法读取 `~/.claude.json` 回来确认更改。更改可能在磁盘上,也可能不在。括号中的文本是该读取的错误。3256您针对 `user` 或 `local` [作用域](/docs/zh-CN/mcp#mcp-installation-scopes)中的服务器运行了 `claude mcp add`、`claude mcp add-json` 或 `claude mcp remove`,而 Claude Code 无法重新读取 `~/.claude.json` 来确认更改。该更改可能已写入磁盘,也可能没有。括号中的文本是该次读取的错误。
3193 3257
3194```text theme={null}3258```text theme={null}
3195MCP server "example" may not have been saved: /home/user/.claude.json could not be read to confirm the change (EACCES: permission denied, open '/home/user/.claude.json'). Run `claude mcp get example` to check, then add the server again if it is missing.3259MCP server "example" may not have been saved: /home/user/.claude.json could not be read to confirm the change (EACCES: permission denied, open '/home/user/.claude.json'). Run `claude mcp get example` to check, then add the server again if it is missing.
3196```3260```
3197 3261
3198删除后,消息读取 `may not have been removed` 并以 `then remove the server again if it is still listed` 结尾。3262执行移除操作后,消息会显示为 `may not have been removed`,并以 `then remove the server again if it is still listed` 结尾。
3199 3263
3200在 v2.1.283 之前,命令即使更改无法确认也报告成功。3264在 v2.1.283 之前,即使无法确认更改,这些命令也会报告成功。
3201 3265
3202**应该做什么:**3266**解决方法:**
3203 3267
3204* 运行 `claude mcp get <name>` 检查更改是否在磁盘上。对于 `local` 范围服务器,从服务器所属的项目目录运行它,因为本地范围是每个项目的。3268* 运行 `claude mcp get <name>` 检查更改是否已写入磁盘。对于 `local` 作用域的服务器,请从该服务器所属的项目目录中运行,因为本地作用域是按项目划分的。
3205* 如果服务器在添加后丢失,或在删除后仍然列出,请再次运行相同的添加或删除命令。3269* 如果添加后服务器不存在,或移除后服务器仍被列出,请再次运行相同的添加或移除命令。
3206 3270
3207<h3 id="anthropic-hosted-and-doesnt-support-local-oauth">3271<h3 id="anthropic-hosted-and-doesnt-support-local-oauth">
3208 服务器是 Anthropic 托管的,不支持本地 OAuth3272 服务器由 Anthropic 托管,不支持本地 OAuth
3209</h3>3273</h3>
3210 3274
3211您为 MCP 服务器启动了登录,其 URL 指向通过第三方身份提供商进行身份验证的 Anthropic 托管连接器主机。这些主机包括 `microsoft365.mcp.claude.com`、`gmail.mcp.claude.com` 和 `gcal.mcp.claude.com`。Claude Code 拒绝为这些主机从 `/mcp` 面板和 `claude mcp login` 启动其本地 OAuth 流,因为[它们的登录仅通过 claude.ai 工作](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai)。3275您为某个 MCP 服务器发起了登录,而该服务器的 URL 指向通过第三方身份提供商进行身份验证的 Anthropic 托管连接器主机。这些主机包括 `microsoft365.mcp.claude.com`、`gmail.mcp.claude.com` 和 `gcal.mcp.claude.com`。无论是从 `/mcp` 面板还是 `claude mcp login`,Claude Code 都会拒绝为这些主机启动本地 OAuth 流程,因为[它们的登录只能通过 claude.ai 完成](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai)。
3212 3276
3213```text theme={null}3277```text theme={null}
3214"gmail" is Anthropic-hosted and doesn't support local OAuth. Connect it via Settings → Connectors on claude.ai (requires `claude login`), then it'll be available here automatically.3278"gmail" is Anthropic-hosted and doesn't support local OAuth. Connect it via Settings → Connectors on claude.ai (requires `claude login`), then it'll be available here automatically.
3215```3279```
3216 3280
3217**应该做什么:**3281**解决方法:**
3218 3282
3219* 使用 `claude mcp remove <name>` 删除您的条目,以便它不能隐藏同一 URL 处的 claude.ai 连接器3283* 使用 `claude mcp remove <name>` 移除您的条目,以免它遮蔽同一 URL 上的 claude.ai 连接器
3220* 删除后,在 [claude.ai/customize/connectors](https://claude.ai/customize/connectors) 连接服务,同时登录到您在 Claude Code 中使用的帐户。连接后,如果您的活跃身份验证方法是 claude.ai 订阅登录,[连接器会自动出现在 Claude Code 中](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai)3284* 移除之后,在登录您在 Claude Code 中使用的账户的情况下,在 [claude.ai/customize/connectors](https://claude.ai/customize/connectors) 连接该服务。连接后,如果您当前的身份验证方式是 claude.ai 订阅登录,[该连接器会自动出现在 Claude Code 中](/docs/zh-CN/mcp#use-mcp-servers-from-claude-ai)
3221 3285
3222<h3 id="server-rejected-the-authorization-header-minted-by-the-configured-headershelper">3286<h3 id="server-rejected-the-authorization-header-minted-by-the-configured-headershelper">
3223 服务器拒绝了由配置的 headersHelper 生成的 Authorization 标头3287 服务器拒绝了所配置 headersHelper 生成的 Authorization 标头
3224</h3>3288</h3>
3225 3289
3226其 [`headersHelper`](/docs/zh-CN/mcp#use-dynamic-headers-for-custom-authentication) 提供 `Authorization` 标头的 MCP 服务器以 HTTP 401 或 403 回答连接,所以 Claude Code 将连接报告为失败。因为助手提供 `Authorization` 标头,Claude Code [不会回退到 OAuth](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers) 对于服务器:3290某个由 [`headersHelper`](/docs/zh-CN/mcp#use-dynamic-headers-for-custom-authentication) 提供 `Authorization` 标头的 MCP 服务器以 HTTP 401 或 403 响应了连接,因此 Claude Code 报告连接失败。由于该 helper 提供了 `Authorization` 标头,Claude Code 对该服务器[不会回退到 OAuth](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers):
3227 3291
3228```text theme={null}3292```text theme={null}
3229Server rejected the Authorization header minted by the configured headersHelper (HTTP 401). Check that the helper command returns a valid credential for this MCP endpoint — OAuth fallback is disabled when the helper supplies Authorization.3293Server rejected the Authorization header minted by the configured headersHelper (HTTP 401). Check that the helper command returns a valid credential for this MCP endpoint — OAuth fallback is disabled when the helper supplies Authorization.
3230```3294```
3231 3295
3232Claude Code 在每次连接尝试时重新运行助手,所以在短暂拒绝后重试,例如令牌轮换竞争,可以使用新凭证成功。3296Claude Code 在每次连接尝试时都会重新运行该 helper,因此在暂时性拒绝(例如令牌轮换竞争)之后重试,可能会凭借新的凭据成功。
3233 3297
3234**应该做什么:**3298**解决方法:**
3235 3299
3236* 按照 Claude Code 运行它的方式自己运行 `headersHelper` 命令:从 [Claude Code 运行它的目录](/docs/zh-CN/mcp#where-the-helper-runs),使用 [Claude Code 为其设置的环境变量](/docs/zh-CN/mcp#use-dynamic-headers-for-custom-authentication),以及不使用 [Claude Code 为来自项目 `.mcp.json`、插件或项目代理文件的服务器删除的凭证变量](/docs/zh-CN/mcp#which-variables-a-helper-can-read)。检查它是否打印服务器端点接受的 `Authorization` 值3300* 按照 Claude Code 运行它的方式自行运行 `headersHelper` 命令:在 [Claude Code 运行它的目录](/docs/zh-CN/mcp#where-the-helper-runs)中运行,使用 [Claude Code 为它设置的环境变量](/docs/zh-CN/mcp#use-dynamic-headers-for-custom-authentication),并且对于来自项目 `.mcp.json`、插件或项目 Agent 文件的服务器,不带有 [Claude Code 移除的凭据变量](/docs/zh-CN/mcp#which-variables-a-helper-can-read)。检查它是否输出了服务器端点所接受的 `Authorization` 值
3237* 修复助手或其凭证源后,在 `/mcp` 中选择服务器并选择**重新连接**3301* 修复 helper 或其凭据来源后,在 `/mcp` 中选择该服务器并选择 **Reconnect**
3238 3302
3239在 v2.1.248 之前,Claude Code 为其助手提供 `Authorization` 标头的服务器运行 OAuth 发现。该发现可能失败,显示 `Incompatible auth server: does not support dynamic client registration` 而不是报告被拒绝的凭证。3303在 v2.1.248 之前,对于由 helper 提供 `Authorization` 标头的服务器,Claude Code 会运行 OAuth 发现。该发现可能会以 `Incompatible auth server: does not support dynamic client registration` 失败,而不是报告被拒绝的凭据。
3240 3304
3241<h3 id="mcp-permission-prompt-tool-not-found">3305<h3 id="mcp-permission-prompt-tool-not-found">
3242 未找到 MCP 权限提示工具3306 未找到 MCP 权限提示工具
3243</h3>3307</h3>
3244 3308
3245您传递给 [`--permission-prompt-tool`](/docs/zh-CN/cli-reference#cli-flags) 的工具在运行首次需要权限决定时不在连接的 MCP 工具中,要么因为其服务器从未连接,要么因为没有连接的服务器公开该名称的工具。Claude Code 仍然发送您的提示:[非交互](/docs/zh-CN/headless)运行在第一个工具调用时以此错误和退出代码 1 退出,所以即使请求已发出,它也不会产生答案。在第一个提示之前,Claude Code 等待最多由 [`MCP_TIMEOUT`](/docs/zh-CN/env-vars) 设置的每个服务器连接超时 30 秒,以便该服务器连接。在 v2.1.206 之前,启动不等待服务器完成连接,所以启动缓慢但健康的服务器也会产生此错误。3309当运行首次需要权限决策时,您传给 [`--permission-prompt-tool`](/docs/zh-CN/cli-reference#cli-flags) 的工具不在已连接的 MCP 工具之中,原因可能是其服务器从未连接,或者没有已连接的服务器公开该名称的工具。Claude Code 仍会发送您的提示词:[非交互](/docs/zh-CN/headless)运行会在第一次工具调用时以此错误和退出码 1 退出,因此即使请求已经发出,也不会产生回答。在第一个提示词之前,Claude Code 会等待该服务器连接,最长等待时间为 [`MCP_TIMEOUT`](/docs/zh-CN/env-vars) 设置的每服务器连接超时时间 30 秒。在 v2.1.206 之前,启动时不会等待服务器完成连接,因此启动较慢但运行正常的服务器也会产生此错误。
3246 3310
3247```text theme={null}3311```text theme={null}
3248Error: MCP tool mcp__permissions__approve (passed via --permission-prompt-tool) not found. Available MCP tools: none3312Error: MCP tool mcp__permissions__approve (passed via --permission-prompt-tool) not found. Available MCP tools: none
3249```3313```
3250 3314
3251`Available MCP tools:` 后的列表命名已连接的 MCP 工具。3315`Available MCP tools:` 之后的列表列出了已连接的 MCP 工具。
3252 3316
3253**应该做什么:**3317**解决方法:**
3254 3318
3255* 检查服务器启动并保持连接:在同一目录中运行 `claude mcp list` 并确认服务器列为已连接3319* 检查服务器是否能启动并保持连接:在同一目录中运行 `claude mcp list`,确认该服务器显示为已连接
3256* 确认工具名称与服务器公开的 `mcp__<server>__<tool>` 名称匹配3320* 确认工具名称与服务器公开的 `mcp__<server>__<tool>` 名称一致
3257* 如果服务器需要超过 30 秒才能启动,请提高 [`MCP_TIMEOUT`](/docs/zh-CN/env-vars)3321* 如果服务器启动需要超过 30 秒,请调高 [`MCP_TIMEOUT`](/docs/zh-CN/env-vars)
3258 3322
3259<h3 id="oauth-callback-port-is-already-in-use">3323<h3 id="oauth-callback-port-is-already-in-use">
3260 OAuth 回调端口已在使用中3324 OAuth 回调端口已被占用
3261</h3>3325</h3>
3262 3326
3263当您使用 OAuth 登录远程 MCP 服务器时,Claude Code 启动本地侦听器以接收登录回调。如果该侦听器需要的端口被另一个进程持有,登录失败,显示此消息。这主要发生在[固定回调端口](/docs/zh-CN/mcp#use-a-fixed-oauth-callback-port)通过 [`MCP_OAUTH_CALLBACK_PORT`](/docs/zh-CN/env-vars) 变量或 `--callback-port` 设置时,因为没有一个 Claude Code 会选择可用端口。3327当您使用 OAuth 登录远程 MCP 服务器时,Claude Code 会启动一个本地监听器来接收登录回调。如果该监听器所需的端口被另一个进程占用,登录会以此消息失败。这种情况主要发生在通过 [`MCP_OAUTH_CALLBACK_PORT`](/docs/zh-CN/env-vars) 变量或 `--callback-port` 设置了[固定回调端口](/docs/zh-CN/mcp#use-a-fixed-oauth-callback-port)时,因为如果没有设置,Claude Code 会选择一个可用端口。
3264 3328
3265```text theme={null}3329```text theme={null}
3266OAuth callback port <port> is already in use — another process may be holding it. Run `lsof -ti:<port> -sTCP:LISTEN` to find it.3330OAuth callback port <port> is already in use — another process may be holding it. Run `lsof -ti:<port> -sTCP:LISTEN` to find it.
3267```3331```
3268 3332
3269在 Windows 上,建议的命令是 `netstat -ano | findstr :<port>`。3333在 Windows 上,建议的命令改为 `netstat -ano | findstr :<port>`。
3270 3334
3271**应该做什么:**3335**解决方法:**
3272 3336
3273* 运行消息中的命令以找到持有端口的进程,并停止它或等待它完成3337* 运行消息中的命令,找到占用该端口的进程,然后停止它或等待它结束
3274* 如果另一个程序永久需要该端口,请向服务器注册不同的重定向 URI,并使用 `MCP_OAUTH_CALLBACK_PORT` 或 `--callback-port` 设置其端口,以及您使用的任何一个3338* 如果另一个程序需要长期占用该端口,请向服务器注册一个不同的重定向 URI,并使用 `MCP_OAUTH_CALLBACK_PORT` 或 `--callback-port`(取决于您使用的是哪一个)设置其端口
3275* 然后再次启动登录,例如通过在 `/mcp` 中选择服务器3339* 然后重新发起登录,例如在 `/mcp` 中选择该服务器
3276 3340
3277<h3 id="no-available-ports-for-oauth-redirect">3341<h3 id="no-available-ports-for-oauth-redirect">
3278 OAuth 重定向没有可用的端口3342 没有可用于 OAuth 重定向的端口
3279</h3>3343</h3>
3280 3344
3281当您使用[OAuth](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers)登录远程 MCP 服务器时,Claude Code 启动本地侦听器以接收登录回调。当 Claude Code 无法为其绑定本地端口时,登录失败,显示此消息。机器上的某些内容阻止它在 `127.0.0.1` 上侦听,例如安全软件或拒绝本地侦听器的沙箱策略。3345当您使用 [OAuth](/docs/zh-CN/mcp#authenticate-with-remote-mcp-servers) 登录远程 MCP 服务器时,Claude Code 会启动一个本地监听器来接收登录回调。当 Claude Code 无法为其绑定本地端口时,登录会以此消息失败。这说明计算机上的某些东西阻止它在 `127.0.0.1` 上监听,例如拒绝本地监听器的安全软件或沙箱策略。
3282 3346
3283```text theme={null}3347```text theme={null}
3284No available ports for OAuth redirect3348No available ports for OAuth redirect
3285```3349```
3286 3350
3287在 v2.1.268 之前,Claude Code 不会回退到操作系统分配的端口,所以消息也会在仅其自选端口无法绑定时出现。这可能发生在 Hyper-V 保留覆盖 Claude Code 选择的端口的端口范围的 Windows 主机上。3351在 v2.1.268 之前,Claude Code 不会回退到由操作系统分配的端口,因此当只是它自行选择的端口无法绑定时,也会出现此消息。这种情况可能发生在 Hyper-V 保留了覆盖 Claude Code 选择范围的端口区间的 Windows 主机上。
3288 3352
3289**应该做什么:**3353**解决方法:**
3290 3354
3291* 检查安全软件或沙箱策略是否阻止进程在 `127.0.0.1` 上侦听,并允许 Claude Code 绑定本地端口3355* 检查是否有安全软件或沙箱策略阻止进程在 `127.0.0.1` 上监听,并允许 Claude Code 绑定本地端口
3292* 然后再次启动登录,例如通过在 `/mcp` 中选择服务器3356* 然后重新发起登录,例如在 `/mcp` 中选择该服务器
3293 3357
3294<h3 id="security-review-fails-without-origin-head">3358<h3 id="security-review-fails-without-origin-head">
3295 /security-review 在没有 origin/HEAD 时失败3359 缺少 origin/HEAD 时 /security-review 失败
3296</h3>3360</h3>
3297 3361
3298[`/security-review`](/docs/zh-CN/commands#all-commands) 通过将您的分支与 `origin/HEAD` 进行比较来构建其审查上下文,这是记录您的 `origin` 远程上哪个分支是默认分支的本地 ref。当该 ref 不存在时,收集差异的 git 命令失败,审查在启动前停止。3362[`/security-review`](/docs/zh-CN/commands#all-commands) 通过将您的分支与 `origin/HEAD` 进行 diff 来构建审查上下文,`origin/HEAD` 是记录 `origin` 远程默认分支的本地引用。当该引用不存在时,收集 diff 的 git 命令会失败,审查在开始之前就会停止。
3299 3363
3300```text theme={null}3364```text theme={null}
3301Error: Shell command failed for pattern "!`git diff --name-only origin/HEAD...`": [stderr]3365Error: Shell command failed for pattern "!`git diff --name-only origin/HEAD...`": [stderr]
3304'git <command> [<revision>...] -- [<file>...]'3368'git <command> [<revision>...] -- [<file>...]'
3305```3369```
3306 3370
3307消息可能引用 `git log` 或不同的 `git diff`。Git 仅在远程通告默认分支且您的获取 refspec 覆盖它时创建 `origin/HEAD`,完整的远程克隆带有提交时会这样做。在这些设置中 ref 丢失:3371消息中引用的也可能是 `git log` 或其他 `git diff` 命令。只有当远程公布了默认分支且您的 fetch refspec 覆盖了该分支时,Git 才会创建 `origin/HEAD`;对含有提交的远程执行完整的 `git clone` 就满足这一点。在以下设置中会缺少该引用:
3308 3372
3309* 单分支或 CI 检出,它获取太窄的 refspec3373* 单分支或 CI 检出,其 fetch refspec 范围过窄
3310* 远程服务器端 HEAD 指向没有人推送的分支3374* 服务器端 HEAD 指向一个无人推送过的分支的远程
3311* 没有 `origin` 远程的存储库,或您从未获取的存储库3375* 没有 `origin` 远程的仓库,或您从未 fetch 过的仓库
3312 3376
3313Claude Code 为任何 [injects dynamic context](/docs/zh-CN/skills#when-an-injected-command-fails) 的 skill 显示相同的错误,失败的注入命令会中止该 skill 的调用。两个兄弟字符串在命令运行之前就会触发:3377对于任何[注入动态上下文](/docs/zh-CN/skills#when-an-injected-command-fails)的 skill,Claude Code 都会显示相同的错误,并且注入的命令失败会中止该 skill 的调用。另有两条相关消息会在命令实际运行之前触发:
3314 3378
3315* `Shell command permission check failed for pattern "..."`:命令的权限检查不允许它。[Permission checks on injected commands](/docs/zh-CN/skills#permission-checks-on-injected-commands) 涵盖在每个权限模式中哪些结果会中止,以及如何使用 `allowed-tools` 预先批准命令3379* `Shell command permission check failed for pattern "..."`:命令的权限检查未允许它运行。[注入命令的权限检查](/docs/zh-CN/skills#permission-checks-on-injected-commands)介绍了在各权限模式下哪些结果会导致中止,以及如何使用 `allowed-tools` 预先批准命令
3316* ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found``:skill 的 frontmatter 在没有它的机器上要求 bash。安装 Git for Windows 或将 frontmatter 更改为 `shell: powershell`。请参阅[注入命令如何运行](/docs/zh-CN/skills#how-injected-commands-run)3380* ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found``:该 skill 的 frontmatter 要求使用 bash,但计算机上没有 bash。请安装 Git for Windows,或将 frontmatter 改为 `shell: powershell`。请参阅[注入命令的运行方式](/docs/zh-CN/skills#how-injected-commands-run)
3317 3381
3318**应该做什么:**3382**解决方法:**
3319 3383
3320* 通过命名您的远程默认分支创建 ref:`git remote set-head origin <default-branch>`。只要本地跟踪 ref `origin/<default-branch>` 存在,这就有效。如果它不存在,如在单分支克隆中,首先获取分支:运行 `git remote set-branches --add origin <branch>`,然后 `git fetch origin`,然后重新运行 set-head 命令。重新运行 `/security-review`。3384* 通过指定远程的默认分支来创建该引用:`git remote set-head origin <default-branch>`。只要本地跟踪引用 `origin/<default-branch>` 存在,此方法就有效。如果它不存在(例如在单分支克隆中),请先 fetch 该分支:运行 `git remote set-branches --add origin <branch>`,然后运行 `git fetch origin`,再重新运行 set-head 命令。然后重新运行 `/security-review`。
3321* 如果您不想命名分支,运行 `git fetch origin` 然后 `git remote set-head origin --auto`,它询问远程其默认分支是什么。当远程不通告默认分支时它失败,显示 `error: Cannot determine remote HEAD`,因为它是空的或其 HEAD 指向没有人推送的分支;改为显式命名分支。当您的克隆不获取该分支时它失败,显示 `error: Not a valid ref`;首先按上面的方式扩大 refspec。3385* 如果您不想指定分支名称,请运行 `git fetch origin`,然后运行 `git remote set-head origin --auto`,它会向远程查询哪个分支是默认分支。当远程未公布默认分支时(因为远程为空,或其 HEAD 指向无人推送过的分支),它会以 `error: Cannot determine remote HEAD` 失败;此时请显式指定分支。当您的克隆不 fetch 该分支时,它会以 `error: Not a valid ref` 失败;请先按上述方法扩大 refspec。
3322* 如果存储库没有远程,使用 `git remote add origin <url>` 添加一个并在创建 ref 之前获取。如果远程是空的,首先使用 `git push -u origin HEAD` 推送您的分支,并在 set-head 命令中命名该分支;`origin/HEAD` 然后指向您刚推送的分支,所以 `/security-review` 看到空差异,直到分支与其分歧。3386* 如果仓库没有远程,请使用 `git remote add origin <url>` 添加一个,并在创建引用之前执行 fetch。如果远程为空,请先使用 `git push -u origin HEAD` 推送您的分支,并在 set-head 命令中指定该分支;之后 `origin/HEAD` 会指向您刚推送的分支,因此在您的分支与其产生分歧之前,`/security-review` 看到的 diff 为空。
3323 3387
3324<h3 id="input-must-be-provided-when-using-print">3388<h3 id="input-must-be-provided-when-using-print">
3325 使用 `--print` 时必须提供输入3389 使用 `--print` 时必须提供输入
3326</h3>3390</h3>
3327 3391
3328裸 `claude` 需要 stdout 是终端才能启动交互 UI。当 stdout 被重定向,或控制台不是真实终端时,例如 PowerShell ISE 和某些 IDE 输出窗格,`claude` 改为以[非交互](/docs/zh-CN/headless)模式运行。这与 `claude -p` 相同,它需要提示,所以消息命名 `--print`,即使您没有传递标志。在任何地方传递 `-p`/`--print` 而不带提示且 stdin 上没有任何内容会产生相同的错误。3392直接运行 `claude` 需要 stdout 是终端才能启动交互式 UI。当 stdout 被重定向,或控制台不是真正的终端(例如 PowerShell ISE 和某些 IDE 输出窗格)时,`claude` 会改为以[非交互方式](/docs/zh-CN/headless)运行。这与 `claude -p` 的模式相同,而该模式需要提示词,因此即使您没有传入该标志,消息中也会提到 `--print`。在任何环境中,传入 `-p`/`--print` 却不提供提示词且 stdin 上没有管道输入,都会产生同样的错误。
3329 3393
3330```text theme={null}3394```text theme={null}
3331Error: Input must be provided either through stdin or as a prompt argument when using --print3395Error: Input must be provided either through stdin or as a prompt argument when using --print
3332```3396```
3333 3397
3334**应该做什么:**3398**解决方法:**
3335 3399
3336* 对于交互使用,在真实终端中运行 `claude`:Windows Terminal 或 PowerShell 控制台而不是 ISE,以及您的 IDE 的集成终端而不是输出窗格3400* 若要交互式使用,请在真正的终端中运行 `claude`:使用 Windows Terminal 或 PowerShell 控制台而不是 ISE,使用 IDE 的集成终端而不是输出窗格
3337* 对于一次性使用,传递提示:`claude -p "your question"`,或使用 `echo "your question" | claude -p` 管道它3401* 若要一次性使用,请传入提示词:`claude -p "your question"`,或通过管道传入:`echo "your question" | claude -p`
3338 3402
3339<h3 id="input-contained-only-whitespace">3403<h3 id="input-contained-only-whitespace">
3340 输入仅包含空格3404 输入仅包含空白字符
3341</h3>3405</h3>
3342 3406
3343在[非交互模式](/docs/zh-CN/headless)中,Claude Code 拒绝完全由空格、制表符或换行符组成的提示,而不是发送它,因为 API 拒绝没有可见文本的消息。您看到的消息取决于空白提示来自何处:3407在[非交互模式](/docs/zh-CN/headless)下,Claude Code 会拒绝完全由空格、制表符或换行符组成的提示词,而不会发送它,因为 API 会拒绝没有可见文本的消息。您看到的消息取决于空白提示词的来源:
3344 3408
3345* **`claude -p` 的提示参数或管道 stdin**:`claude` 以 `Error: Input contained only whitespace. Provide a prompt with text through stdin or as a prompt argument when using --print` 退出3409* **`claude -p` 的提示词参数或通过管道传入的 stdin**:`claude` 以 `Error: Input contained only whitespace. Provide a prompt with text through stdin or as a prompt argument when using --print` 退出
3346* **提交给运行 `--input-format stream-json` 或 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 会话的消息**:Claude Code 在不调用模型的情况下结束轮次,会话保持可用。拒绝作为信息消息和轮次的结果文本到达:`Blank prompt — the message was only whitespace, so nothing was sent to the model.`3410* **提交到正在运行的 `--input-format stream-json` 或 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 会话的消息**:Claude Code 会在不调用模型的情况下结束该轮次,会话仍可继续使用。拒绝信息会以信息性消息以及该轮次结果文本的形式出现:`Blank prompt — the message was only whitespace, so nothing was sent to the model.`
3347 3411
3348在 v2.1.229 之前,Claude Code 将仅空格消息发送到 API,API 以 400 错误拒绝请求。3412在 v2.1.229 之前,Claude Code 会将仅含空白字符的消息发送到 API,而 API 会以 400 错误拒绝该请求。
3349 3413
3350**应该做什么:**3414**解决方法:**
3351 3415
3352* 在提示中包含可见文本。如果脚本从变量或文件构建提示,请在调用 Claude Code 之前检查源是否不为空。3416* 在提示词中包含可见文本。如果脚本从变量或文件构建提示词,请在调用 Claude Code 之前检查来源是否为空。
3353 3417
3354<h3 id="stream-json-input-carried-over-256m-characters-with-no-newline">3418<h3 id="stream-json-input-carried-over-256m-characters-with-no-newline">
3355 stream-json 输入在没有换行符的情况下超过 256M 个字符3419 stream-json 输入超过 256M 个字符且没有换行符
3356</h3>3420</h3>
3357 3421
3358您的程序在没有换行符的情况下在 stdin 上发送了超过 268,435,456 个字符到 `claude -p --input-format stream-json` 运行,所以 Claude Code 将此错误打印到 stderr 并以代码 1 退出,而不是缓冲更多输入。消息将该预算表示为 `256M`。在 v2.1.257 之前,Claude Code 无限制地缓冲此类输入,增长内存直到进程崩溃或被杀死。3422您的程序向 `claude -p --input-format stream-json` 运行的 stdin 发送了超过 268,435,456 个字符且没有换行符,因此 Claude Code 会将此错误打印到 stderr 并以退出码 1 退出,而不会继续缓冲更多输入。消息将该上限表述为 `256M`。在 v2.1.257 之前,Claude Code 会无限制地缓冲此类输入,内存不断增长,直到进程崩溃或被终止。
3359 3423
3360```text theme={null}3424```text theme={null}
3361Error: stream-json input carried over 256M characters with no newline. Each stream-json message must be a single newline-terminated JSON line: either the producer is not newline-terminating its messages, or one message exceeded this budget.3425Error: stream-json input carried over 256M characters with no newline. Each stream-json message must be a single newline-terminated JSON line: either the producer is not newline-terminating its messages, or one message exceeded this budget.
3362```3426```
3363 3427
3364没有换行符的这么长的输入通常意味着生产者根本不是 stream-json 生产者,例如二进制文件或意外管道的纯日志输出。超过预算的单个消息失败相同的检查。3428这么长却没有换行符的输入通常意味着生成方根本不是 stream-json 生成方,例如意外通过管道传入的二进制文件或纯日志输出。单条超过上限的消息也会在同一检查中失败。
3365 3429
3366**应该做什么:**3430**解决方法:**
3367 3431
3368* 检查什么被管道到 stdin。使用 [`--input-format stream-json`](/docs/zh-CN/cli-reference#cli-flags),每条消息必须是一个换行符终止的 JSON 行3432* 检查通过管道传入 stdin 的内容。使用 [`--input-format stream-json`](/docs/zh-CN/cli-reference#cli-flags) 时,每条消息都必须是一行以换行符结尾的 JSON
3369* 要改为发送纯文本,请删除 `--input-format stream-json`;`claude -p` 默认从 stdin 读取纯文本提示3433* 若要改为发送纯文本,请去掉 `--input-format stream-json`;`claude -p` 默认从 stdin 读取纯文本提示词
3370 3434
3371<h3 id="unknown-command">3435<h3 id="unknown-command">
3372 未知命令3436 未知命令
3373</h3>3437</h3>
3374 3438
3375在交互终端会话中,您提交了一个 `/` 名称,它与此会话中的任何命令都不匹配,所以 Claude Code 报告该名称而不是运行任何内容:3439在交互式终端会话中,您提交了一个与本会话中任何命令都不匹配的 `/` 名称,因此 Claude Code 会报告该名称,而不会运行任何内容:
3376 3440
3377```text theme={null}3441```text theme={null}
3378Unknown command: /hepl. Did you mean /help?3442Unknown command: /hepl. Did you mean /help?
3379```3443```
3380 3444
3381Claude Code 建议此会话中菜单列出的最接近的命令名称或别名。当没有接近的时候,消息在名称后结束。原因通常是以下之一:3445Claude Code 会建议本会话菜单中列出的最接近的命令名称或别名。当没有接近的匹配时,消息会在名称之后结束。原因通常是以下之一:
3382 3446
3383* 打字错误,例如 `/hepl` 代替 `/help`。[How the command menu matches what you type](/docs/zh-CN/commands#how-the-command-menu-matches-what-you-type) 涵盖在提交前选择接近的匹配3447* 拼写错误,例如将 `/help` 输成 `/hepl`。[命令菜单如何匹配您的输入](/docs/zh-CN/commands#how-the-command-menu-matches-what-you-type)介绍了如何在提交前选择接近的匹配项
3384* 存在但在此会话中不可用的命令,因为不满足要求,例如您的平台、计划或身份验证方法。[`/web-setup`](/docs/zh-CN/web-quickstart#web-setup-shows-no-commands-match-or-unknown-command) 和 [`/schedule`](/docs/zh-CN/routines#schedule-returns-unknown-command) 的故障排除条目演示两个常见情况。某些命令在您的组织的策略禁用它们时用自己的消息回答,例如 [`Cloud sessions are disabled by your organization's policy`](#cloud-sessions-are-disabled-by-your-organizations-policy)3448* 命令存在,但由于未满足某项要求(例如您的平台、套餐或身份验证方式)而在本会话中不可用。[`/web-setup`](/docs/zh-CN/web-quickstart#web-setup-shows-no-commands-match-or-unknown-command) 和 [`/schedule`](/docs/zh-CN/routines#schedule-returns-unknown-command) 的故障排除条目介绍了两种常见情况。当您组织的策略禁用某些命令时,这些命令会以其自身的消息回复,例如 [`Cloud sessions are disabled by your organization's policy`](#cloud-sessions-are-disabled-by-your-organizations-policy)
3385* 来自[插件](/docs/zh-CN/plugins/overview)或[MCP 服务器](/docs/zh-CN/mcp#use-mcp-prompts-as-commands)的命令,在此会话中未安装或连接3449* 来自[插件](/docs/zh-CN/plugins/overview)或 [MCP 服务器](/docs/zh-CN/mcp#use-mcp-prompts-as-commands)的命令,但该插件或服务器未在本会话中安装或连接
3386 3450
3387Claude Code 仅在交互终端会话中以这种方式回答不匹配的 `/` 名称。在所有其他会话中,它将提示作为正常消息发送给 Claude,并注意命令未运行以及 Claude 可以在会话中运行的命令列表。这些会话包括:3451只有在交互式终端会话中,Claude Code 才会以这种方式回应不匹配的 `/` 名称。在其他所有会话中,它会改为将提示词作为普通消息发送给 Claude,并附上一条说明该命令未运行的备注,以及 Claude 在该会话中可以运行的命令列表。这些会话包括:
3388 3452
3389* `-p` 运行3453* `-p` 运行
3390* [Agent SDK](/docs/zh-CN/agent-sdk/overview) 应用程序3454* [Agent SDK](/docs/zh-CN/agent-sdk/overview) 应用程序
3391* [Desktop 应用](/docs/zh-CN/desktop)的代码选项卡3455* [桌面应用](/docs/zh-CN/desktop)的 Code 选项卡
3392* [VS Code 扩展](/docs/zh-CN/vs-code)的聊天面板3456* [VS Code 扩展](/docs/zh-CN/vs-code)的聊天面板
3393* [云会话](/docs/zh-CN/claude-code-on-the-web)和[例程](/docs/zh-CN/routines)3457* [云端会话](/docs/zh-CN/claude-code-on-the-web)和 [Routine](/docs/zh-CN/routines)
3394 3458
3395对于无法在这些会话之一中运行的内置命令,Claude Code 仍然回答命令不可用,而不是将其发送给 Claude。在 v2.1.274 之前,仅云会话和例程将不匹配的名称发送给 Claude。在 v2.1.273 之前,它们也回答 `Unknown command`。3459对于无法在这些会话之一中运行的内置命令,Claude Code 仍会回复该命令不可用,而不是将其发送给 Claude。在 v2.1.274 之前,只有云端会话和 Routine 会将不匹配的名称发送给 Claude。在 v2.1.273 之前,它们也会回复 `Unknown command`。
3396 3460
3397Claude Code 不将每个以 `/` 开头的提示视为命令。当 `/` 后的第一个单词以标点符号开头时,它将提示作为正常消息发送给 Claude,例如打开 Lean doc 注释的 `/--`,或是路径,例如 `/var/log/syslog`。3461Claude Code 并不会将每个以 `/` 开头的提示词都视为命令。当 `/` 之后的第一个单词以标点符号开头(例如开启 Lean 文档注释的 `/--`),或者是 `/var/log/syslog` 之类的路径时,它会将提示词作为普通消息发送给 Claude。
3398 3462
3399在 v2.1.236 之前,如果您在命令菜单列出您键入的名称的接近匹配时按 `Enter`,Claude Code 会运行该匹配,所以 `/hepl` 之类的打字错误会运行 `/help` 而不是产生此消息。3463在 v2.1.236 之前,如果您在命令菜单列出与您输入的名称相近的匹配项时按下 `Enter`,Claude Code 会运行该匹配项,因此 `/hepl` 之类的拼写错误会运行 `/help`,而不是产生此消息。
3400 3464
3401**应该做什么:**3465**解决方法:**
3402 3466
3403* 运行建议的名称,或键入 `/` 后跟名称的一部分以查看此会话中可用的内容3467* 运行建议的名称,或输入 `/` 后跟名称的一部分,查看本会话中可用的内容
3404* 如果 Claude Code 将记录的命令报告为未知,请检查[命令参考](/docs/zh-CN/commands)中的其行以了解它命名的要求3468* 如果 Claude Code 将某个有文档记录的命令报告为未知,请在[命令参考](/docs/zh-CN/commands)中查看该命令所在行指出的要求
3405 3469
3406<h3 id="diff-is-too-large-for-ultrareview">3470<h3 id="diff-is-too-large-for-ultrareview">
3407 Diff 对于 ultrareview 来说太大了3471 diff 过大,无法进行 ultrareview
3408</h3>3472</h3>
3409 3473
3410您的分支和基础分支之间的差异,包括未提交和暂存的更改,超过了 [ultrareview](/docs/zh-CN/ultrareview) 的大小限制,所以 `/code-review ultra` 和 `claude ultrareview` 子命令在云会话启动前拒绝审查。被拒绝的审查不使用免费运行,也不计费使用信用。消息命名有效的限制、您的差异大小以及贡献最多更改行的文件。在 v2.1.216 之前,消息仅显示原始差异统计。3474您的分支与基础分支之间的 diff(包括未提交和已暂存的更改)超出了 [ultrareview](/docs/zh-CN/ultrareview) 的大小限制,因此 `/code-review ultra` 和 `claude ultrareview` 子命令会在云端会话启动之前拒绝审查。被拒绝的审查不会消耗免费运行次数,也不会扣除使用额度。消息会列出当前生效的限制、您的 diff 大小,以及贡献更改行数最多的文件。在 v2.1.216 之前,消息只显示原始的 diff 统计信息。
3411 3475
3412```text theme={null}3476```text theme={null}
3413Diff is too large for ultrareview: 812 files, 96,410 lines changed (limits: 500 files, 8,000 lines). Largest files: package-lock.json (41,904 lines), dist/bundle.js (18,210 lines), src/generated/api.ts (9,876 lines). Pass a closer base branch (`/code-review ultra <branch>`) to narrow the scope, or split the change.3477Diff is too large for ultrareview: 812 files, 96,410 lines changed (limits: 500 files, 8,000 lines). Largest files: package-lock.json (41,904 lines), dist/bundle.js (18,210 lines), src/generated/api.ts (9,876 lines). Pass a closer base branch (`/code-review ultra <branch>`) to narrow the scope, or split the change.
3414```3478```
3415 3479
3416审查拉取请求应用相同的限制;该形式的消息以 `PR #<N> is too large for ultrareview` 开头,并命名 PR 的文件和行数。3480审查 Pull Request 时也适用相同的限制;该形式的消息以 `PR #<N> is too large for ultrareview` 开头,并列出该 PR 的文件数和行数。
3417 3481
3418**应该做什么:**3482**解决方法:**
3419 3483
3420* 传递更接近您的工作的基础分支,例如 `/code-review ultra develop`,以便审查仅涵盖与该分支的差异3484* 传入一个更接近您工作内容的基础分支,例如 `/code-review ultra develop`,使审查只覆盖相对于该分支的 diff
3421* 将更改分成较小的分支并审查每一个。消息命名的文件贡献最多更改行,所以首先将这些移到它们自己的分支。3485* 将更改拆分为较小的分支并分别审查。消息中列出的文件贡献了最多的更改行数,因此可以先将这些文件移到单独的分支中。
3422 3486
3423<h3 id="could-not-find-merge-base-with-the-base-branch">3487<h3 id="could-not-find-merge-base-with-the-base-branch">
3424 无法找到与基础分支的合并基础3488 无法找到与基础分支的 merge-base
3425</h3>3489</h3>
3426 3490
3427`/code-review ultra` 和 `claude ultrareview` 子命令审查您的分支和基础分支之间的差异,这需要两者共享的提交。当 `git merge-base` 找不到时,Claude Code 在云会话启动前拒绝审查。在 Claude Code 可以验证完整的克隆上,至少有一个分支,它改为回退到[审查每个跟踪文件](/docs/zh-CN/ultrareview#diff-limits-and-fallbacks)而不是拒绝。您在基础分支根本找不到时、Claude Code 无法验证您的克隆完整时,或在罕见的存储库中看到此拒绝,其中整个树差异不可能,例如 SHA-256 对象格式。3491`/code-review ultra` 和 `claude ultrareview` 子命令会审查您的分支与基础分支之间的 diff,这需要两者共有的一个提交。当 `git merge-base` 找不到这样的提交时,Claude Code 会在云端会话启动之前拒绝审查。在 Claude Code 能够验证为完整且至少有一个分支的克隆上,它会回退为[审查每个被跟踪的文件](/docs/zh-CN/ultrareview#diff-limits-and-fallbacks),而不是拒绝。当根本找不到基础分支、Claude Code 无法验证您的克隆是否完整,或在少数无法进行全树 diff 的仓库中(例如使用 SHA-256 对象格式的仓库),您会看到此拒绝。
3428 3492
3429```text theme={null}3493```text theme={null}
3430Could not find merge-base with main. Pass the base branch explicitly (e.g. `/code-review ultra develop`) or make sure you're in a git repo with a main branch.3494Could not find merge-base with main. Pass the base branch explicitly (e.g. `/code-review ultra develop`) or make sure you're in a git repo with a main branch.
3431```3495```
3432 3496
3433第一句后的提示取决于 Claude Code 观察到的内容:3497第一句之后的提示取决于 Claude Code 观察到的情况:
3434 3498
3435* **您没有传递基础分支**:Claude Code 与存储库的默认分支进行了比较,并建议显式传递您的基础,如上面的示例3499* **您未传入基础分支**:Claude Code 与仓库的默认分支进行了比较,并建议您显式传入基础分支,如上例所示
3436* **您传递的基础分支已在您的克隆中**:提示读取 ``Make sure <branch> exists locally or on origin (try `git fetch origin <branch>`)``3500* **您传入的基础分支已存在于您的克隆中**:提示为 ``Make sure <branch> exists locally or on origin (try `git fetch origin <branch>`)``
3437* **您传递的基础分支不在您的克隆中**:Claude Code 在比较前从 origin 获取了它。提示读取 ``<branch> was fetched from origin but shares no history with HEAD. If another branch is your real base, pass it explicitly (`/code-review ultra <branch>`)``;当 Claude Code 无法判断您的克隆是否浅时,它改为建议 `git fetch --unshallow origin`。在 v2.1.221 之前,提示为每个获取的基础分支建议 `git fetch --unshallow origin`,在完整克隆上该命令失败,显示 `fatal: --unshallow on a complete repository does not make sense`。3501* **您传入的基础分支不在您的克隆中**:Claude Code 在比较之前从 origin fetch 了该分支。提示为 ``<branch> was fetched from origin but shares no history with HEAD. If another branch is your real base, pass it explicitly (`/code-review ultra <branch>`)``;当 Claude Code 无法判断您的克隆是否为浅克隆时,它会改为建议 `git fetch --unshallow origin`。在 v2.1.221 之前,对于每个被 fetch 的基础分支,提示都会建议 `git fetch --unshallow origin`,而在完整克隆上,该命令会以 `fatal: --unshallow on a complete repository does not make sense` 失败。
3438 3502
3439**应该做什么:**3503**解决方法:**
3440 3504
3441* 如果另一个分支是您的真实基础,显式传递它:`/code-review ultra <branch>`3505* 如果您真正的基础分支是另一个分支,请显式传入:`/code-review ultra <branch>`
3442* 如果您的克隆可能没有完整历史,运行 `git fetch --unshallow origin` 并重新运行审查3506* 如果您的克隆可能没有完整历史,请运行 `git fetch --unshallow origin` 并重新运行审查
3443 3507
3444<h3 id="your-checkout-has-no-branches">3508<h3 id="your-checkout-has-no-branches">
3445 您的检出没有分支3509 您的检出没有分支
3446</h3>3510</h3>
3447 3511
3448检出可以有提交但没有分支:如果您运行 `git init` 后跟 `git fetch <url>` 和 `git checkout FETCH_HEAD`,您会得到一个分离的 HEAD,没有 refs。Claude Code 将您的存储库打包为 git 包以上传它进行 [ultrareview](/docs/zh-CN/ultrareview),它无法打包没有分支或其他 refs 的存储库,所以 `/code-review ultra` 和 `claude ultrareview` 子命令在云会话启动前拒绝审查。3512检出可能有提交但没有分支:如果您运行 `git init`,然后运行 `git fetch <url>` 和 `git checkout FETCH_HEAD`,就会得到一个没有任何引用的分离 HEAD。Claude Code 会将您的仓库打包为 git bundle 并上传以进行 [ultrareview](/docs/zh-CN/ultrareview),而它无法打包没有分支或其他引用的仓库,因此 `/code-review ultra` 和 `claude ultrareview` 子命令会在云端会话启动之前拒绝审查。
3449 3513
3450```text theme={null}3514```text theme={null}
3451Your checkout has no branches (detached HEAD only), which cloud review can't bundle. Create one first — `git checkout -b <name>` — then rerun /code-review ultra.3515Your checkout has no branches (detached HEAD only), which cloud review can't bundle. Create one first — `git checkout -b <name>` — then rerun /code-review ultra.
3452```3516```
3453 3517
3454在 v2.1.221 之前,Claude Code 尝试审查此检出中的每个跟踪文件,上传失败。3518在 v2.1.221 之前,Claude Code 会尝试审查此检出中每个被跟踪的文件,而上传会失败。
3455 3519
3456**应该做什么:**3520**解决方法:**
3457 3521
3458* 使用 `git checkout -b <name>` 在您当前的提交处创建分支,然后重新运行审查3522* 使用 `git checkout -b <name>` 在当前提交处创建一个分支,然后重新运行审查
3459 3523
3460<h3 id="no-github-account-is-connected-to-your-claude-account">3524<h3 id="no-github-account-is-connected-to-your-claude-account">
3461 没有 GitHub 帐户连接到您的 Claude 帐户3525 您的 Claude 账户未连接 GitHub 账户
3462</h3>3526</h3>
3463 3527
3464您运行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,在创建云会话前 Claude Code 询问服务器[连接到您的 Claude 帐户的 GitHub 帐户](/docs/zh-CN/ultrareview#review-a-pull-request)是否可以到达 PR 的存储库。没有帐户连接,或连接已过期,所以云克隆会失败,Claude Code 拒绝启动。Claude Code 不为被拒绝的启动花费免费运行或计费使用信用。3528您运行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,在创建云端会话之前,Claude Code 会询问服务器[连接到您 Claude 账户的 GitHub 账户](/docs/zh-CN/ultrareview#review-a-pull-request)是否能访问该 PR 的仓库。由于没有连接账户,或连接已过期,云端克隆将会失败,因此 Claude Code 拒绝启动。对于被拒绝的启动,Claude Code 不会消耗免费运行次数,也不会扣除使用额度。
3465 3529
3466```text theme={null}3530```text theme={null}
3467Ultrareview clones <owner>/<repo> in the cloud with the GitHub account connected to your Claude account, and none is connected (or the connection expired). To fix: run /web-setup to reuse your GitHub CLI login, or connect an account at https://claude.ai/connect-github — then re-run /code-review ultra 1234 (allow a minute after connecting).3531Ultrareview clones <owner>/<repo> in the cloud with the GitHub account connected to your Claude account, and none is connected (or the connection expired). To fix: run /web-setup to reuse your GitHub CLI login, or connect an account at https://claude.ai/connect-github — then re-run /code-review ultra 1234 (allow a minute after connecting).
3468```3532```
3469 3533
3470当 [`/web-setup`](/docs/zh-CN/web-quickstart#connect-from-your-terminal) 在您的会话中不可用时,消息仅命名 claude.ai 链接。3534当 [`/web-setup`](/docs/zh-CN/web-quickstart#connect-from-your-terminal) 在您的会话中不可用时,消息只会提到 claude.ai 链接。
3471 3535
3472**应该做什么:**3536**解决方法:**
3473 3537
3474* 运行 `/web-setup` 将您的 GitHub CLI 登录连接到您的 Claude 帐户,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 连接帐户3538* 运行 `/web-setup` 将您的 GitHub CLI 登录连接到 Claude 账户,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 连接账户
3475* 连接后一分钟重新运行审查3539* 连接后等待一分钟再重新运行审查
3476 3540
3477在 v2.1.248 之前,Claude Code 在启动前不检查这个。3541在 v2.1.248 之前,Claude Code 在启动前不会进行此检查。
3478 3542
3479<h3 id="your-connected-github-account-cant-see-the-repository">3543<h3 id="your-connected-github-account-cant-see-the-repository">
3480 您连接的 GitHub 帐户看不到存储库3544 您连接的 GitHub 账户无法看到该仓库
3481</h3>3545</h3>
3482 3546
3483您运行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,[连接到您的 Claude 帐户的 GitHub 帐户](/docs/zh-CN/ultrareview#review-a-pull-request)无法读取 PR 的存储库,所以云克隆会失败,Claude Code 拒绝启动。Claude Code 不为被拒绝的启动花费免费运行或计费使用信用。3547您运行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,而[连接到您 Claude 账户的 GitHub 账户](/docs/zh-CN/ultrareview#review-a-pull-request)无法读取该 PR 的仓库,因此云端克隆将会失败,Claude Code 拒绝启动。对于被拒绝的启动,Claude Code 不会消耗免费运行次数,也不会扣除使用额度。
3484 3548
3485```text theme={null}3549```text theme={null}
3486Your connected GitHub account can't see <owner>/<repo> — usually the Claude GitHub app isn't installed on <owner> or wasn't granted this repo (web-connected accounts need it for private repos), or a different GitHub account is connected. To fix: run /web-setup to reuse your GitHub CLI login, or install the app at https://github.com/apps/claude/installations/new — then re-run /code-review ultra 1234.3550Your connected GitHub account can't see <owner>/<repo> — usually the Claude GitHub app isn't installed on <owner> or wasn't granted this repo (web-connected accounts need it for private repos), or a different GitHub account is connected. To fix: run /web-setup to reuse your GitHub CLI login, or install the app at https://github.com/apps/claude/installations/new — then re-run /code-review ultra 1234.
3487```3551```
3488 3552
3489当 [`/web-setup`](/docs/zh-CN/web-quickstart#connect-from-your-terminal) 在您的会话中不可用时,消息仅命名应用安装。3553当 [`/web-setup`](/docs/zh-CN/web-quickstart#connect-from-your-terminal) 在您的会话中不可用时,消息只会提到应用安装。
3490 3554
3491**应该做什么:**3555**解决方法:**
3492 3556
3493* 如果您的本地 `gh` CLI 可以读取存储库,运行 `/web-setup` 将该登录连接到您的 Claude 帐户3557* 如果您本地的 `gh` CLI 可以读取该仓库,请运行 `/web-setup` 将该登录连接到您的 Claude 账户
3494* 更改后重新运行审查3558* 更改后重新运行审查
3495 3559
3496在 v2.1.248 之前,Claude Code 在启动前不检查这个。3560在 v2.1.248 之前,Claude Code 在启动前不会进行此检查。
3497 3561
3498<h3 id="the-github-app-preflight-failed-transiently">3562<h3 id="the-github-app-preflight-failed-transiently">
3499 GitHub App 预检暂时失败3563 GitHub App 预检暂时失败
3500</h3>3564</h3>
3501 3565
3502您从本地存储库启动了[云会话](/docs/zh-CN/claude-code-on-the-web),两个步骤一起失败了。Claude Code 无法构建或上传您的存储库包。在上传之前,它检查了云服务是否可以从 GitHub 克隆存储库,而不是明确的答案,该检查以重试可能清除的错误结束,例如网络错误、超时或临时服务器错误。完整消息以停止包的内容开头,例如 `Could not upload repo bundle (<error>)`,并以预检句子结尾:3566您从本地仓库启动了一个[云端会话](/docs/zh-CN/claude-code-on-the-web),而两个步骤同时失败。Claude Code 无法构建或上传您仓库的 bundle。在上传之前,它检查了云服务能否从 GitHub 克隆该仓库,而该检查没有得到明确答案,而是以一个重试可能消除的错误结束,例如网络错误、超时或临时服务器错误。完整消息以导致 bundle 失败的原因开头,例如 `Could not upload repo bundle (<error>)`,并以预检相关的句子结尾:
3503 3567
3504```text theme={null}3568```text theme={null}
3505Could not upload repo bundle (<error>). The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead3569Could not upload repo bundle (<error>). The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead
3506```3570```
3507 3571
3508**应该做什么:**3572**解决方法:**
3509 3573
3510* 片刻后重新运行命令。当 GitHub 检查通过时,Claude Code 可以从 GitHub 克隆启动会话,所以失败的上传不再阻止启动3574* 稍后重新运行命令。当 GitHub 检查通过时,Claude Code 可以从 GitHub 克隆启动会话,因此上传失败将不再阻止启动
3511* 如果重试继续失败,消息的开头命名停止上传的内容。当该原因是您可以修复的内容时,修复它以便会话可以从您的本地存储库启动3575* 如果重试一直失败,消息开头会指出导致上传失败的原因。如果该原因是您可以修复的,请修复它,以便会话可以改为从您的本地仓库启动
3512 3576
3513在 v2.1.251 之前,Claude Code 以 `Please set up GitHub on https://claude.ai/code` 结束消息,即使 GitHub 检查仅暂时失败,设置建议无法清除暂时失败。3577在 v2.1.251 之前,即使 GitHub 检查只是暂时失败,Claude Code 也会以 `Please set up GitHub on https://claude.ai/code` 结束消息,而设置建议无法消除暂时性故障。
3514 3578
3515<h3 id="the-repository-upload-cant-follow-a-git-setting">3579<h3 id="the-repository-upload-cant-follow-a-git-setting">
3516 存储库上传无法遵循 git 设置3580 仓库上传无法遵循某项 git 设置
3517</h3>3581</h3>
3518 3582
3519您启动了[上传您的本地存储库的云会话](/docs/zh-CN/claude-code-on-the-web#send-local-repositories-without-github),或分支的 [ultrareview](/docs/zh-CN/ultrareview),上传无法遵循决定哪个属性规则适用于您的文件的 git 设置之一。如果上传继续并错过了规则,git 在存储它之前转换的文件,例如清理过滤器加密的文件,可能会到达云端,因为它在磁盘上。Claude Code 拒绝上传,什么都不上传:3583您启动了一个[上传本地仓库的云端会话](/docs/zh-CN/claude-code-on-the-web#send-local-repositories-without-github),或对某个分支进行 [ultrareview](/docs/zh-CN/ultrareview),而上传无法遵循决定哪些属性规则适用于您文件的某项 git 设置。如果上传继续进行并遗漏了某条规则,那么 git 在存储前会转换的文件(例如经 clean 过滤器加密的文件)可能会以其在磁盘上的原样到达云端。因此 Claude Code 会拒绝上传,不会上传任何内容:
3520 3584
3521```text theme={null}3585```text theme={null}
3522Not uploading this working tree: core.ignoreCase (which decides whether .gitattributes patterns match file names regardless of letter case) is set in <file>, and the upload cannot follow that setting, so a file git would change before storing it (to encrypt it, for example) could be uploaded as it is on disk. Move the core.ignoreCase line into this repository's .git/config or directly into your ~/.gitconfig, then retry.3586Not uploading this working tree: core.ignoreCase (which decides whether .gitattributes patterns match file names regardless of letter case) is set in <file>, and the upload cannot follow that setting, so a file git would change before storing it (to encrypt it, for example) could be uploaded as it is on disk. Move the core.ignoreCase line into this repository’s .git/config or directly into your ~/.gitconfig, then retry.
3523```3587```
3524 3588
3525消息命名设置和它的设置位置,并以该情况的修复结尾。相同的拒绝出现在 `core.attributesFile` 和 `attr.tree`,每个都有自己的修复。3589消息会指出该设置及其设置位置,并以针对您所遇情况的修复方法结尾。对于 `core.attributesFile` 和 `attr.tree`,也会出现同样的拒绝,各自附有对应的修复方法。
3526 3590
3527消息可以命名您的 git 配置通过 `include` 或 `includeIf` 指令拉入的配置文件,即使该指令的条件不适用于此存储库。3591消息中指出的配置文件可能是您的 git 配置通过 `include` 或 `includeIf` 指令引入的,即使该指令的条件并不适用于此仓库。
3528 3592
3529**应该做什么:**3593**解决方法:**
3530 3594
3531* 应用消息最后一句中的修复3595* 按照消息最后一句中的修复方法操作
3532 3596
3533<h3 id="github-isnt-connected-to-your-claude-account">3597<h3 id="github-isnt-connected-to-your-claude-account">
3534 GitHub 未连接到您的 Claude 帐户3598 GitHub 未连接到您的 Claude 账户
3535</h3>3599</h3>
3536 3600
3537您从本地存储库启动了[云会话](/docs/zh-CN/claude-code-on-the-web),例如使用 `/autofix-pr`。没有 GitHub 帐户连接到您的 Claude 帐户,或连接已过期,所以 Claude Code 拒绝启动:3601您从本地仓库启动了一个[云端会话](/docs/zh-CN/claude-code-on-the-web),例如使用 `/autofix-pr`。您的 Claude 账户未连接 GitHub 账户,或连接已过期,因此 Claude Code 拒绝启动:
3538 3602
3539```text theme={null}3603```text theme={null}
3540GitHub isn't connected to your Claude account, so this repository can't be cloned in the cloud. Run /web-setup to connect with your GitHub CLI login, or connect on the web at https://claude.ai/connect-github3604GitHub isn't connected to your Claude account, so this repository can't be cloned in the cloud. Run /web-setup to connect with your GitHub CLI login, or connect on the web at https://claude.ai/connect-github
3541```3605```
3542 3606
3543当您使用 [`/schedule`](/docs/zh-CN/routines) 创建例程时,相同的消息作为命名存储库的设置注释出现;注释不会阻止创建例程。3607当您使用 [`/schedule`](/docs/zh-CN/routines) 创建 Routine 时,同样的消息会作为指出该仓库的设置说明出现;该说明不会阻止创建 Routine。
3544 3608
3545**应该做什么:**3609**解决方法:**
3546 3610
3547* 运行 `/web-setup` 将您的 GitHub CLI 登录连接到您的 Claude 帐户,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 连接帐户。请参阅[GitHub 身份验证选项](/docs/zh-CN/claude-code-on-the-web#github-authentication-options)了解两者的区别。3611* 运行 `/web-setup` 将您的 GitHub CLI 登录连接到 Claude 账户,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 连接账户。有关两者的区别,请参阅 [GitHub 身份验证选项](/docs/zh-CN/claude-code-on-the-web#github-authentication-options)。
3548* 连接后一分钟重新运行命令3612* 连接后等待一分钟再重新运行命令
3549 3613
3550在 v2.1.268 之前,Claude Code 将此报告为 Claude GitHub App 检查的临时失败,并建议重试或安装应用;两者都不连接 GitHub 帐户。3614在 v2.1.268 之前,Claude Code 会将此情况报告为 Claude GitHub App 检查的暂时性失败,并建议重试或安装该应用;但这两种做法都无法连接 GitHub 账户。
3551 3615
3552<h3 id="single-sign-on-authorization-needed">3616<h3 id="single-sign-on-authorization-needed">
3553 需要单点登录授权3617 需要单点登录授权
3554</h3>3618</h3>
3555 3619
3556您运行了 [`/install-github-app`](/docs/zh-CN/github-actions#quick-setup),并选择了其组织强制执行 SAML 单点登录的存储库。在设置之前,Claude Code 使用 GitHub CLI 检查您对存储库的访问权限,GitHub 拒绝了该检查,因为您的 `gh` 令牌还没有为组织授权。向导显示警告和授权步骤:3620您运行了 [`/install-github-app`](/docs/zh-CN/github-actions#quick-setup),并选择了一个其组织强制执行 SAML 单点登录的仓库。在设置之前,Claude Code 会使用 GitHub CLI 检查您对该仓库的访问权限,而 GitHub 拒绝了该检查,因为您的 `gh` 令牌尚未获得该组织的授权。向导会显示警告以及授权步骤:
3557 3621
3558```text theme={null}3622```text theme={null}
3559Single sign-on authorization needed3623Single sign-on authorization needed
3560<owner>/<repo> belongs to an organization that enforces SAML single sign-on, and your GitHub CLI token isn't authorized for it yet.3624<owner>/<repo> belongs to an organization that enforces SAML single sign-on, and your GitHub CLI token isn't authorized for it yet.
3561```3625```
3562 3626
3563**应该做什么:**3627**解决方法:**
3564 3628
3565* 通过运行 `gh auth refresh -h github.com -s repo,workflow` 使用 `repo` 和 `workflow` 范围重新授权您的 GitHub CLI 登录,并在 GitHub 提示单点登录时授权组织3629* 运行 `gh auth refresh -h github.com -s repo,workflow`,以 `repo` 和 `workflow` 作用域重新授权您的 GitHub CLI 登录,并在 GitHub 提示单点登录时授权该组织
3566* 如果您使用 `GH_TOKEN` 中的个人访问令牌进行身份验证,请打开 [github.com/settings/tokens](https://github.com/settings/tokens),在令牌上选择**配置 SSO**,并授权组织3630* 如果您使用 `GH_TOKEN` 中的个人访问令牌进行身份验证,请打开 [github.com/settings/tokens](https://github.com/settings/tokens),在该令牌上选择 **Configure SSO**,并授权该组织
3567* 再次运行 `/install-github-app`3631* 再次运行 `/install-github-app`
3568 3632
3569在 v2.1.273 之前,Claude Code 为此条件显示 `Admin permissions required` 警告。3633在 v2.1.273 之前,Claude Code 在这种情况下会改为显示 `Admin permissions required` 警告。
3570 3634
3571<h3 id="failed-to-resume-the-conversation">3635<h3 id="failed-to-resume-the-conversation">
3572 无法恢复对话3636 恢复对话失败
3573</h3>3637</h3>
3574 3638
3575Claude Code 无法读取或处理您从 [`claude --resume` 选择器](/docs/zh-CN/sessions#use-the-session-picker)选择的会话的保存成绩单,所以它结束进程而不是在部分加载状态下继续。消息包括重试的命令:3639Claude Code 无法读取或处理您从 [`claude --resume` 选择器](/docs/zh-CN/sessions#use-the-session-picker)中选择的会话的已保存会话记录,因此会结束进程,而不是在部分加载的状态下继续。消息中包含用于重试的命令:
3576 3640
3577```text theme={null}3641```text theme={null}
3578Failed to resume the conversation.3642Failed to resume the conversation.
3579Run claude --resume <session-id> to retry, or claude to start a new session.3643Run claude --resume <session-id> to retry, or claude to start a new session.
3580```3644```
3581 3645
3582Claude Code 显示消息后以代码 1 退出。运行会话内的 `/resume` 选择器报告对话中的 `Failed to resume conversation`,您当前的会话保持运行。在 v2.1.216 之前,来自 `claude --resume` 选择器的失败恢复在 `Resuming conversation…` 微调器上无限期停留,而不是显示此消息。3646显示该消息后,Claude Code 以退出码 1 退出。正在运行的会话中的 `/resume` 选择器则会在对话中报告 `Failed to resume conversation`,而您当前的会话会继续运行。在 v2.1.216 之前,从 `claude --resume` 选择器恢复失败时,会一直停留在 `Resuming conversation…` 加载动画上,而不是显示此消息。
3583 3647
3584**应该做什么:**3648**解决方法:**
3585 3649
3586* 使用消息中的会话 ID 运行 `claude --resume <session-id>` 重试3650* 使用消息中的会话 ID 运行 `claude --resume <session-id>` 进行重试
3587* 如果每次重试都以相同的方式失败,运行 `claude update` 并再次恢复。v2.1.275 之前的版本在保存的成绩单包含它们无法读取的条目时恢复失败。3651* 在 v2.1.285 之前的版本上,如果重试以同样的方式失败,请运行 `claude update` 后再次恢复。当已保存的会话记录包含这些版本无法读取的条目时,这些版本会恢复失败。
3588* 如果重试再次失败,运行 `claude` 启动新会话3652* 如果重试再次失败,请运行 `claude` 启动新会话
3589 3653
3590<h3 id="no-conversation-found-with-the-session-id">3654<h3 id="no-conversation-found-with-the-session-id">
3591 未找到具有会话 ID 的对话3655 No conversation found with the session ID
3592</h3>3656</h3>
3593 3657
3594您将会话 ID 传递给 `claude --resume <session-id>`,没有保存的成绩单与其匹配:3658您向 `claude --resume <session-id>` 传入了一个会话 ID,但没有任何已保存的会话记录与之匹配:
3595 3659
3596```text theme={null}3660```text theme={null}
3597No conversation found with session ID: <session-id>3661No conversation found with session ID: <session-id>
3598```3662```
3599 3663
3600Claude Code 显示消息后以代码 1 退出。Claude Code [首先搜索当前项目,然后搜索此机器上的所有其他项目](/docs/zh-CN/sessions#resume-a-session)以查找 ID。在 v2.1.223 之前,查找停止在当前项目目录及其 git worktrees,所以从会话最后工作的目录恢复。3664显示该消息后,Claude Code 以退出码 1 退出。Claude Code 会[先在当前项目中搜索该 ID,然后在本机的所有其他项目中搜索](/docs/zh-CN/sessions#resume-a-session)。在 v2.1.223 之前,查找范围仅限于当前项目目录及其 git worktree,因此需要从该会话最后工作的目录中恢复会话。
3601 3665
3602常见原因:3666常见原因:
3603 3667
3604* **打字错误的 ID**:对于非交互运行,ID 是 [`--output-format json` 输出](/docs/zh-CN/headless#get-structured-output)的 `session_id` 字段3668* **ID 输入错误**:对于非交互式运行,ID 是 [`--output-format json` 输出](/docs/zh-CN/headless#get-structured-output)中的 `session_id` 字段
3605* **删除的成绩单**:Claude Code 在[保留期](/docs/zh-CN/sessions#where-transcripts-are-stored)后删除成绩单,默认 30 天,遵循[保留扫描规则](/docs/zh-CN/claude-directory#cleaned-up-automatically)3669* **会话记录已删除**:Claude Code 会在[保留期](/docs/zh-CN/sessions#where-transcripts-are-stored)(默认 30 天)之后按照[保留清理规则](/docs/zh-CN/claude-directory#cleaned-up-automatically)删除会话记录
3606* **不同的机器**:Claude Code 在本地存储成绩单,所以在运行它的机器上恢复会话3670* **不同的机器**:Claude Code 将会话记录存储在本地,因此请在运行该会话的机器上恢复它
3607* **重复副本**:如果您在 `~/.claude/projects` 下复制了项目目录,所以两个成绩单携带相同的 ID,Claude Code 报告此消息而不是任意恢复一个副本3671* **重复副本**:如果您复制了 `~/.claude/projects` 下的某个项目目录,导致两个会话记录带有相同的 ID,Claude Code 会报告此消息,而不是任意恢复其中一个副本
3608 3672
3609**应该做什么:**3673**处理方法:**
3610 3674
3611* 对于交互会话,使用 `claude --resume` 打开[会话选择器](/docs/zh-CN/sessions#use-the-session-picker),按 `Ctrl+A` 将其扩展到此机器上的每个项目,然后选择会话3675* 对于交互式会话,使用 `claude --resume` 打开[会话选择器](/docs/zh-CN/sessions#use-the-session-picker),按 `Ctrl+A` 将范围扩大到本机的所有项目,然后选择该会话
3612* 使用 `claude -p` 或 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 创建的会话不会出现在选择器中,所以重新检查 ID 与您的原始运行打印的 `session_id`3676* 使用 `claude -p` 或 [Agent SDK](/docs/zh-CN/agent-sdk/overview) 创建的会话不会出现在选择器中,因此请对照原始运行输出的 `session_id` 重新核对 ID
3613 3677
3614<h3 id="windows-reported-an-error-ebadf">3678<h3 id="windows-reported-an-error-ebadf">
3615 Windows 在 Claude Code 读取此会话的成绩单文件时报告了错误 (EBADF)3679 Windows reported an error (EBADF) when Claude Code read this session's transcript file
3616</h3>3680</h3>
3617 3681
3618您在 Windows 上恢复了会话,其保存的[成绩单文件](/docs/zh-CN/sessions#where-transcripts-are-stored)正常打开,读取它然后失败,显示系统错误 EBADF。系统错误没有说读取失败的原因,所以消息建议可能的原因和要尝试的内容:3682您在 Windows 上恢复了一个会话,其已保存的[会话记录文件](/docs/zh-CN/sessions#where-transcripts-are-stored)正常打开,但随后读取时因系统错误 EBADF 而失败。该系统错误并未说明读取失败的原因,因此该消息会列出可能的原因以及可尝试的操作:
3619 3683
3620```text theme={null}3684```text theme={null}
3621Windows reported an error (EBADF) when Claude Code read this session's transcript file, although the file had opened normally. This can happen when other software intercepts file reads — security, encryption or endpoint-management tools, for example. If it keeps happening for this conversation, try excluding the folder that holds Claude Code's session transcripts from such software (the .claude folder in your user profile, unless the app or CLAUDE_CONFIG_DIR points Claude Code elsewhere), or adding Claude Code to its allowed applications, then resume again.3685Windows reported an error (EBADF) when Claude Code read this session's transcript file, although the file had opened normally. This can happen when other software intercepts file reads — security, encryption or endpoint-management tools, for example. If it keeps happening for this conversation, try excluding the folder that holds Claude Code's session transcripts from such software (the .claude folder in your user profile, unless the app or CLAUDE_CONFIG_DIR points Claude Code elsewhere), or adding Claude Code to its allowed applications, then resume again.
3622```3686```
3623 3687
3624消息遵循命令自己的失败行,例如 `Failed to resume session <session-id>`。`claude --resume` 或 [`claude -p`](/docs/zh-CN/headless) 命令显示它后以代码 1 退出。在会话内的 `/resume` 后,您当前的会话保持运行。3688该消息紧跟在命令自身的失败行之后,例如 `Failed to resume session <session-id>`。`claude --resume` 或 [`claude -p`](/docs/zh-CN/headless) 命令在显示该消息后以退出码 1 退出。如果是在会话中执行 `/resume`,您当前的会话会继续运行。
3625 3689
3626**应该做什么:**3690**处理方法:**
3627 3691
3628* 从扫描或拦截文件读取的软件(例如安全、加密或端点管理工具)中排除保存会话成绩单的文件夹。成绩单默认位于 `%USERPROFILE%\.claude\projects` 下,或位于 [`CLAUDE_CONFIG_DIR`](/docs/zh-CN/env-vars) 命名的目录下3692* 将存放会话记录的文件夹从扫描或拦截文件读取的软件(例如安全、加密或终端管理工具)中排除。会话记录默认位于 `%USERPROFILE%\.claude\projects` 下,或位于 [`CLAUDE_CONFIG_DIR`](/docs/zh-CN/env-vars) 指定的目录下
3629* 如果您无法添加排除,请改为将 Claude Code 添加到该软件的允许应用程序3693* 如果无法添加排除项,请改为将 Claude Code 添加到该软件的允许应用程序中
3630* 再次恢复会话3694* 再次恢复该会话
3631 3695
3632在 v2.1.282 之前,失败没有解释:`claude --resume <session-id>` 在 `Failed to resume session <session-id>` 处结束,`-p` 运行仅打印系统错误文本,例如 `Failed to resume session: EBADF: bad file descriptor, read`。3696在 v2.1.282 之前,该失败不附带任何说明:`claude --resume <session-id>` 以 `Failed to resume session <session-id>` 结束,而 `-p` 运行只输出系统错误文本,例如 `Failed to resume session: EBADF: bad file descriptor, read`。
3633 3697
3634<h3 id="cannot-switch-renderers-in-this-session">3698<h3 id="cannot-switch-renderers-in-this-session">
3635 无法在此会话中切换渲染器3699 Cannot switch renderers in this session
3636</h3>3700</h3>
3637 3701
3638当您切换渲染器时,Claude Code 重新启动其进程。您在 Claude Code 拒绝重新启动的会话中运行了 [`/tui`](/docs/zh-CN/fullscreen#enable-fullscreen-rendering),所以它不切换并保存任何内容。您看到的消息告诉您原因:3702切换渲染器时,Claude Code 会重启其进程。您在一个 Claude Code 拒绝重启的会话中运行了 [`/tui`](/docs/zh-CN/fullscreen#enable-fullscreen-rendering),因此它不会切换,也不会保存任何内容。您看到的消息会指明原因:
3639 3703
3640* `Cannot switch renderers while work is running in the background`:您有在后台运行的工作,重新启动会放弃,例如后台 shell 或子代理。等待工作完成或使用 [`/tasks`](/docs/zh-CN/commands) 停止它,然后再次运行 `/tui fullscreen` 或 `/tui default`3704* `Cannot switch renderers while work is running in the background`:您有正在运行的后台工作,重启会将其丢弃,例如后台 shell 或子代理。请等待工作完成或使用 [`/tasks`](/docs/zh-CN/commands) 停止它,然后再次运行 `/tui fullscreen` 或 `/tui default`
3641* `Cannot switch renderers in this session`:会话有 Claude Code 无法传递给重新启动的进程的限制。在 v2.1.234 之前,Claude Code 无论如何都会重新启动,重新启动的会话运行时没有它们3705* `Cannot switch renderers in this session`:该会话带有 Claude Code 无法传递给重启后进程的限制。在 v2.1.234 之前,Claude Code 仍会重启,而重新启动的会话将不带这些限制运行
3642 3706
3643在限制消息中,括号中的部分命名 Claude Code 找到的限制:3707在限制相关的消息中,括号内的部分列出了 Claude Code 发现的限制:
3644 3708
3645```text theme={null}3709```text theme={null}
3646Cannot switch renderers in this session — it has restrictions a restart can't carry over (permission rules set for this session only). Nothing was changed. Running /tui fullscreen in a session started without them switches every later session too.3710Cannot switch renderers in this session — it has restrictions a restart can't carry over (permission rules set for this session only). Nothing was changed. Running /tui fullscreen in a session started without them switches every later session too.
3647```3711```
3648 3712
3649消息可以在括号中显示的每个原因:3713该消息括号中可能显示的各项原因:
3650 3714
3651* `launch flags: a custom system prompt, a tool allowlist, or restricted settings`:您使用 Claude Code 不传递回重新启动的进程的标志启动了会话。这些标志包括 [`--system-prompt`](/docs/zh-CN/cli-reference#cli-flags)、`--system-prompt-file`、`--append-system-prompt-file`、[`--tools`](/docs/zh-CN/cli-reference#cli-flags) 允许列表、[`--setting-sources`](/docs/zh-CN/cli-reference#cli-flags) 和 [`--permission-prompt-tool`](/docs/zh-CN/cli-reference#cli-flags)3715* `launch flags: a custom system prompt, a tool allowlist, or restricted settings`:您使用了 Claude Code 不会传回给重启后进程的标志启动会话。这些标志包括 [`--system-prompt`](/docs/zh-CN/cli-reference#cli-flags)、`--system-prompt-file`、`--append-system-prompt-file`、[`--tools`](/docs/zh-CN/cli-reference#cli-flags) 允许列表、[`--setting-sources`](/docs/zh-CN/cli-reference#cli-flags) 和 [`--permission-prompt-tool`](/docs/zh-CN/cli-reference#cli-flags)
3652* `permission rules set for this session only`:来自钩子或 SDK 调用者的[权限更新](/docs/zh-CN/hooks#permission-update-entries)添加了带有 `session` 目标的拒绝或询问规则。会话范围的允许规则不会触发拒绝。重新启动会删除它们,Claude Code 改为再次提示3716* `permission rules set for this session only`:来自 hook 或 SDK 调用方的[权限更新](/docs/zh-CN/hooks#permission-update-entries)添加了目标为 `session` 的 deny 或 ask 规则。会话范围的 allow 规则不会触发拒绝。重启会丢弃这些规则,Claude Code 会改为再次提示
3653* `ask-before-running rules with no command-line form`:来自钩子或 SDK 调用者的权限更新添加了询问规则以及 Claude Code 作为 `--allowed-tools` 和 `--disallowed-tools` 传递回的规则。不存在询问规则的标志3717* `ask-before-running rules with no command-line form`:来自 hook 或 SDK 调用方的权限更新在 Claude Code 以 `--allowed-tools` 和 `--disallowed-tools` 传回的规则之外添加了 ask 规则。ask 规则没有对应的标志
3654* `permission rules a command line cannot carry intact` 和 `added directories a command line cannot carry intact`:权限更新在会话中期添加了规则或目录路径。重新启动的进程的命令行无法将其文本作为相同的值继承3718* `permission rules a command line cannot carry intact` 和 `added directories a command line cannot carry intact`:权限更新在会话中途添加了规则或目录路径。重启后进程的命令行无法将其文本作为相同的值传递
3655 3719
3656**应该做什么:**3720**处理方法:**
3657 3721
3658* 在没有这些限制的会话中,运行 `/tui fullscreen`,或 `/tui default` 切换回。Claude Code 在那里保存 [`tui` 设置](/docs/zh-CN/settings-reference#tui)3722* 在不带这些限制启动的会话中运行 `/tui fullscreen`,或运行 `/tui default` 切换回来。Claude Code 会在该会话中保存 [`tui` 设置](/docs/zh-CN/settings-reference#tui)
3659 3723
3660<h3 id="couldnt-open-claude-desktop">3724<h3 id="couldnt-open-claude-desktop">
3661 无法打开 Claude Desktop3725 Couldn't open Claude Desktop
3662</h3>3726</h3>
3663 3727
3664您在会话中运行了 [`/desktop`](/docs/zh-CN/desktop#coming-from-the-cli) 或其别名 `/app`,或在您的 shell 中运行了 [`claude --desktop`](/docs/zh-CN/cli-reference#cli-flags),Claude Code 用来打开 Claude Desktop 的系统命令失败了。在 `/desktop` 后,会话保持在终端中;`claude --desktop` 打印消息而不带 `Error:` 前缀,并以状态 1 退出。3728您在会话中运行了 [`/desktop`](/docs/zh-CN/desktop#coming-from-the-cli) 或其别名 `/app`,或在 shell 中运行了 [`claude --desktop`](/docs/zh-CN/cli-reference#cli-flags),而 Claude Code 用于打开 Claude Desktop 的系统命令失败了。执行 `/desktop` 后,会话仍停留在终端中;`claude --desktop` 会输出不带 `Error:` 前缀的消息并以状态 1 退出。
3665 3729
3666括号中的文本命名失败的命令,带有其退出状态和其错误输出的第一行(如果它产生了)。在 macOS 上该命令是 `open`,如本例所示;在 Windows 上它是 `rundll32`:3730括号中的文本指明失败的命令,以及该命令产生的退出状态和错误输出的第一行(如有)。在 macOS 上,该命令为 `open`,如下例所示;在 Windows 上为 `rundll32`:
3667 3731
3668```text theme={null}3732```text theme={null}
3669Error: Couldn't open Claude Desktop (`open` exited 1: LSOpenURLsWithRole() failed for the URL claude://resume?session=<session-id> with error -10814). Open Claude Desktop and try again.3733Error: Couldn't open Claude Desktop (`open` exited 1: LSOpenURLsWithRole() failed for the URL claude://resume?session=<session-id> with error -10814). Open Claude Desktop and try again.
3670```3734```
3671 3735
3672**应该做什么:**3736**处理方法:**
3673 3737
3674* 自己打开 Claude Desktop,然后再次运行 `/desktop` 或 `claude --desktop`3738* 手动打开 Claude Desktop,然后再次运行 `/desktop` 或 `claude --desktop`
3675* 要读取失败命令的完整错误输出,使用 `/debug` 打开调试日志并再次运行 `/desktop`,或运行 `claude --desktop --debug-file <path>`,然后检查调试日志3739* 要查看失败命令的完整错误输出,请使用 `/debug` 启用调试日志并再次运行 `/desktop`,或运行 `claude --desktop --debug-file <path>`,然后查看调试日志
3676 3740
3677在 v2.1.285 之前,消息以 `Open Claude Desktop and run /desktop again.` 结尾。在 v2.1.275 之前,它是 `Failed to open Claude Desktop. Please try opening it manually.`,没有说什么失败了。3741在 v2.1.285 之前,该消息以 `Open Claude Desktop and run /desktop again.` 结尾。在 v2.1.275 之前,该消息为 `Failed to open Claude Desktop. Please try opening it manually.`,且不说明失败的内容。
3678 3742
3679<h3 id="terminal-setup-left-your-zed-keymap-unchanged">3743<h3 id="terminal-setup-left-your-zed-keymap-unchanged">
3680 /terminal-setup 保持您的 Zed 快捷键不变3744 /terminal-setup left your Zed keymap unchanged
3681</h3>3745</h3>
3682 3746
3683您在 Zed 中运行了 [`/terminal-setup`](/docs/zh-CN/terminal-config#enter-multiline-prompts),Claude Code 无法完成对您的 Zed `keymap.json` 的更新,所以它保持文件不变。3747您在 Zed 中运行了 [`/terminal-setup`](/docs/zh-CN/terminal-config#enter-multiline-prompts),但 Claude Code 无法完成对 Zed `keymap.json` 的更新,因此保留了该文件原样。
3684 3748
3685每条消息命名您的快捷键的路径,并以您自己添加的快捷键块结尾:3749每条消息都会给出您的 keymap 路径,并在末尾附上需要您自行添加的快捷键块:
3686 3750
3687```text theme={null}3751```text theme={null}
3688Couldn't update your Zed keymap, so it was left unchanged.3752Couldn't update your Zed keymap, so it was left unchanged.
3690{ "context": "Terminal", "bindings": { "shift-enter": ["terminal::SendText", "\u001b\r"] } }3754{ "context": "Terminal", "bindings": { "shift-enter": ["terminal::SendText", "\u001b\r"] } }
3691```3755```
3692 3756
3693消息的第一行命名原因:3757消息的第一行指明原因:
3694 3758
3695* `Couldn't read your Zed keymap, so it was left unchanged.`:Claude Code 无法读取文件,例如由于文件权限3759* `Couldn't read your Zed keymap, so it was left unchanged.`:Claude Code 无法读取该文件,例如由于文件权限问题
3696* `Your Zed keymap isn't a readable list of keybindings, so it was left unchanged.`:文件读取正常但不解析为快捷键块数组,即使允许 `//` 注释和尾随逗号3760* `Your Zed keymap isn't a readable list of keybindings, so it was left unchanged.`:文件读取正常,但即使允许 `//` 注释和尾随逗号,也无法解析为快捷键块数组
3697* `Couldn't back up your Zed keymap; not modifying it.`:Claude Code 无法将文件复制到其旁边的 `.bak` 备份,所以它没有更改任何内容3761* `Couldn't back up your Zed keymap; not modifying it.`:Claude Code 无法将该文件复制为同目录下的 `.bak` 备份,因此未做任何更改
3698* `Couldn't update your Zed keymap, so it was left unchanged.`:合并的结果没有验证为携带绑定的有效快捷键,所以 Claude Code 丢弃它而不是写入。具有重复键的快捷键块可能导致这种情况3762* `Couldn't update your Zed keymap, so it was left unchanged.`:合并后的结果未能验证为包含该绑定的有效 keymap,因此 Claude Code 将其丢弃而未写入。包含重复键的快捷键块可能导致此问题
3699 3763
3700**应该做什么:**3764**处理方法:**
3701 3765
3702* 将消息中的块复制到消息命名的路径处 `keymap.json` 中的顶级数组3766* 将消息中的块复制到消息所指路径下 `keymap.json` 的顶层数组中
3703* 对于 `isn't a readable list of keybindings`,修复语法错误,或使文件的顶级值成为数组,然后再次运行 `/terminal-setup`3767* 对于 `isn't a readable list of keybindings`,请修复语法错误,或将文件的顶层值改为数组,然后再次运行 `/terminal-setup`
3704 3768
3705在 v2.1.247 之前,`/terminal-setup` 无法解析使用 `//` 注释或尾随逗号的 Zed 快捷键,它用仅其自己的绑定替换整个文件,同时报告绑定已安装。要恢复较早版本替换的快捷键,请使用[输入多行提示](/docs/zh-CN/terminal-config#enter-multiline-prompts)下描述的 `.bak` 备份文件。3769在 v2.1.247 之前,`/terminal-setup` 无法解析使用 `//` 注释或尾随逗号的 Zed keymap,并且会用仅包含其自身绑定的内容替换整个文件,同时报告绑定已安装。要恢复被早期版本替换的 keymap,请使用[输入多行提示词](/docs/zh-CN/terminal-config#enter-multiline-prompts)中所述的 `.bak` 备份文件。
3706 3770
3707<h3 id="skill-usage-reports-are-not-available-on-this-connection">3771<h3 id="skill-usage-reports-are-not-available-on-this-connection">
3708 Skill 使用报告在此连接上不可用3772 Skill usage reports are not available on this connection
3709</h3>3773</h3>
3710 3774
3711您在[远程控制](/docs/zh-CN/remote-control)上、从您的手机或浏览器运行了 [`/skill-doctor`](/docs/zh-CN/skills#find-unused-skills)。Claude Code 不通过远程控制发送 skill 使用报告,改为用此消息回复:3775您通过 [Remote Control](/docs/zh-CN/remote-control) 从手机或浏览器运行了 [`/skill-doctor`](/docs/zh-CN/skills#find-unused-skills)。Claude Code 不会通过 Remote Control 发送 skill 使用报告,而是回复以下消息:
3712 3776
3713```text theme={null}3777```text theme={null}
3714Skill usage reports are not available on this connection.3778Skill usage reports are not available on this connection.
3715```3779```
3716 3780
3717**应该做什么:**3781**处理方法:**
3718 3782
3719* 在会话运行的机器上的终端中运行 `/skill-doctor`,或在那里运行 `claude -p "/skill-doctor"`3783* 在运行该会话的机器的终端中运行 `/skill-doctor`,或在该机器上运行 `claude -p "/skill-doctor"`
3720 3784
3721<h3 id="custom-output-styles-cant-be-selected-over-remote-control">3785<h3 id="custom-output-styles-cant-be-selected-over-remote-control">
3722 无法通过远程控制选择自定义输出样式3786 Custom output styles can't be selected over Remote Control
3723</h3>3787</h3>
3724 3788
3725您从移动应用或网络通过[远程控制](/docs/zh-CN/remote-control)运行了 [`/output-style`](/docs/zh-CN/output-styles#change-your-output-style),或命令在中继到会话的消息中到达。因为此类轮次可能不来自帐户所有者,Claude Code 仅在其上列出并选择[内置样式](/docs/zh-CN/output-styles#built-in-output-styles),并在命令列出样式或不识别您给出的名称时添加此通知。[自定义样式](/docs/zh-CN/output-styles#create-a-custom-output-style)名称获得与不存在的名称相同的回复:3789您通过 [Remote Control](/docs/zh-CN/remote-control) 从移动应用或网页运行了 [`/output-style`](/docs/zh-CN/output-styles#change-your-output-style),或者该命令来自转发到会话中的消息。由于此类轮次可能并非来自账户所有者,Claude Code 在该轮次中只列出和选择[内置样式](/docs/zh-CN/output-styles#built-in-output-styles),并在命令列出样式或无法识别您提供的名称时附加此提示。[自定义样式](/docs/zh-CN/output-styles#create-a-custom-output-style)名称得到的回复与不存在的名称相同:
3726 3790
3727```text theme={null}3791```text theme={null}
3728Custom output styles can't be selected over Remote Control or from a relayed message. Select one in the session itself, or pick a built-in style here.3792Custom output styles can't be selected over Remote Control or from a relayed message. Select one in the session itself, or pick a built-in style here.
3729```3793```
3730 3794
3731**应该做什么:**3795**处理方法:**
3732 3796
3733* 选择内置样式,例如 `/output-style concise`3797* 选择一个内置样式,例如 `/output-style concise`
3734* 要使用自定义样式,在项目的 `.claude/settings.local.json` 中设置 [`outputStyle`](/docs/zh-CN/settings-reference#outputstyle),或在会话自己的终端中运行 `/output-style <style>`(如果它有的话)3798* 要使用自定义样式,请在项目的 `.claude/settings.local.json` 中设置 [`outputStyle`](/docs/zh-CN/settings-reference#outputstyle),或者如果会话有自己的终端,在该终端中运行 `/output-style <style>`
3735 3799
3736<h3 id="output-styles-are-saved-to-local-settings-which-this-session-doesnt-load">3800<h3 id="output-styles-are-saved-to-local-settings-which-this-session-doesnt-load">
3737 输出样式保存到此会话不加载的本地设置3801 Output styles are saved to local settings which this session doesn't load
3738</h3>3802</h3>
3739 3803
3740您尝试在其设置源排除 `local` 的会话中使用 `/output-style <style>` 或 `/config outputStyle=<style>` 切换[输出样式](/docs/zh-CN/output-styles)。示例是 [`settingSources`](/docs/zh-CN/agent-sdk/typescript#options) 留出 `"local"` 的 [Agent SDK](/docs/zh-CN/agent-sdk/typescript) 会话,以及使用 [`--setting-sources`](/docs/zh-CN/cli-reference#cli-flags) 值启动的 CLI 会话,该值留出 `local`。两个命令都将样式保存到 `.claude/settings.local.json`,此类会话从不读取回的文件,所以 Claude Code 拒绝而不是写入无效的设置:3804您在一个设置来源不包含 `local` 的会话中,尝试使用 `/output-style <style>` 或 `/config outputStyle=<style>` 切换[输出样式](/docs/zh-CN/output-styles)。例如 [`settingSources`](/docs/zh-CN/agent-sdk/typescript#options) 中省略了 `"local"` 的 [Agent SDK](/docs/zh-CN/agent-sdk/typescript) 会话,以及使用省略了 `local` 的 [`--setting-sources`](/docs/zh-CN/cli-reference#cli-flags) 值启动的 CLI 会话。这两个命令都会将样式保存到 `.claude/settings.local.json`,而此类会话从不读取该文件,因此 Claude Code 会拒绝操作,而不是写入一个不会生效的设置:
3741 3805
3742```text theme={null}3806```text theme={null}
3743Output styles are saved to local settings (.claude/settings.local.json), which this session doesn't load, so the style can't be changed here.3807Output styles are saved to local settings (.claude/settings.local.json), which this session doesn't load, so the style can't be changed here.
3744```3808```
3745 3809
3746**应该做什么:**3810**处理方法:**
3747 3811
3748* 将 `local` 添加到会话的设置源并再次切换3812* 将 `local` 添加到会话的设置来源中,然后再次切换
3749* 在会话确实加载的设置文件中设置 [`outputStyle`](/docs/zh-CN/settings-reference#outputstyle) 键,例如项目中的 `.claude/settings.json` 或 `~/.claude/settings.json`。在 TypeScript SDK 中,改为在内联 `settings` 对象内设置 `outputStyle`;请参阅[激活输出样式](/docs/zh-CN/agent-sdk/modifying-system-prompts#activate-an-output-style)3813* 在会话确实会加载的设置文件中设置 [`outputStyle`](/docs/zh-CN/settings-reference#outputstyle) 键,例如项目中的 `.claude/settings.json` 或 `~/.claude/settings.json`。在 TypeScript SDK 中,请改为在内联 `settings` 对象中设置 `outputStyle`;请参阅[激活输出样式](/docs/zh-CN/agent-sdk/modifying-system-prompts#activate-an-output-style)
3750 3814
3751<h2 id="plugin-errors">3815<h2 id="plugin-errors">
3752 插件错误3816 插件错误
4474 后台会话错误4538 后台会话错误
4475</h2>4539</h2>
4476 4540
4477[后台会话](/docs/zh-CN/agent-view)在没有自己的交互式终端的情况下运行,因此需要终端的命令在那里的行为会有所不同。这些消息出现在后台会话的记录中、附加到后台会话的终端中、您分派的会话或 shell 中,或者对于下面的[worktree-guard 条目](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved),出现在任何在 worktree 中隔离的会话或运行 worktree 隔离子代理中;当消息特定于一个表面时,其条目会说明这一点。4541[后台会话](/docs/zh-CN/agent-view)在没有自己的交互式终端的情况下运行,因此需要终端的命令在那里的行为会有所不同。这些消息出现在后台会话的会话记录中、附加到后台会话的终端中、您分派的会话或 shell 中,或者对于下面的[worktree-guard 条目](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved),出现在任何在 worktree 中隔离的会话或运行 worktree 隔离子代理中;当消息特定于一个使用入口时,其条目会说明这一点。
4478 4542
4479<h3 id="commands-refused-in-a-background-session">4543<h3 id="commands-refused-in-a-background-session">
4480 后台会话中拒绝的命令4544 后台会话中拒绝的命令
4481</h3>4545</h3>
4482 4546
4483打开交互式对话框的命令在没有终端附加到后台会话时无法执行。`/install-github-app`、`/mcp` 设置列表和 MCP 服务器菜单中的身份验证操作会响应一条消息。对于 `/install-github-app` 和 `/mcp` 设置列表,该会话也在[代理视图](/docs/zh-CN/agent-view)中的**需要输入**下显示,以便您可以找到它、附加并再次运行该命令。附加终端时,这些命令正常工作。4547打开交互式对话框的命令在没有终端附加到后台会话时无法执行。`/install-github-app`、`/mcp` 设置列表和 MCP 服务器菜单中的身份验证操作会响应一条消息。对于 `/install-github-app` 和 `/mcp` 设置列表,该会话也在 [Agent 视图](/docs/zh-CN/agent-view)中的**需要输入**下显示,以便您可以找到它、附加并再次运行该命令。附加终端时,这些命令正常工作。
4484 4548
4485在 v2.1.216 之前,会话在拒绝 `/install-github-app` 或 `/mcp` 设置列表后不会在**需要输入**下显示。在 v2.1.213 到 v2.1.215 中,附加终端时命令仍然有效,拒绝消息告诉您附加并再次运行该命令。从 v2.1.208 到 v2.1.212,Claude Code 即使附加了终端也拒绝了它们,消息如 `Can't open MCP settings in a background session`;在这些版本上,从常规 `claude` 会话运行该命令,或升级。在 v2.1.208 之前,它们在后台会话内打开了对话框。在仅 v2.1.208 中,Claude Code 也拒绝了后台会话中的 `/model` 选择器,`/upgrade` 打印了升级 URL 而不是打开浏览器。4549在 v2.1.216 之前,会话在拒绝 `/install-github-app` 或 `/mcp` 设置列表后不会在**需要输入**下显示。在 v2.1.213 到 v2.1.215 中,附加终端时命令仍然有效,拒绝消息告诉您附加并再次运行该命令。从 v2.1.208 到 v2.1.212,Claude Code 即使附加了终端也拒绝了它们,消息如 `Can't open MCP settings in a background session`;在这些版本上,从常规 `claude` 会话运行该命令,或升级。在 v2.1.208 之前,它们在后台会话内打开了对话框。在仅 v2.1.208 中,Claude Code 也拒绝了后台会话中的 `/model` 选择器,`/upgrade` 打印了升级 URL 而不是打开浏览器。
4486 4550
4492 4556
4493**要做什么:**4557**要做什么:**
4494 4558
4495* 从代理视图附加到会话并再次运行该命令4559* 从 Agent 视图附加到会话并再次运行该命令
4496* 或使用消息命名的形式,例如 `/mcp reconnect <server>`、`/mcp enable` 或 `/mcp disable`,这些不需要附加即可工作4560* 或使用消息命名的形式,例如 `/mcp reconnect <server>`、`/mcp enable` 或 `/mcp disable`,这些不需要附加即可工作
4497 4561
4498<h3 id="write-or-command-blocked-because-the-path-cannot-be-safely-resolved">4562<h3 id="write-or-command-blocked-because-the-path-cannot-be-safely-resolved">
4509 4573
4510**要做什么:**4574**要做什么:**
4511 4575
4512* 通常什么都不做:完整消息作为工具错误发送给 Claude,Claude 使用它命名的直接路径重试。对于被阻止的文件编辑,对话视图仅显示简短的 `Error editing file` 行;完整消息出现在您使用 `Ctrl+O` 打开的记录视图中。被阻止的命令在其命令输出中打印它。4576* 通常什么都不做:完整消息作为工具错误发送给 Claude,Claude 使用它命名的直接路径重试。对于被阻止的文件编辑,对话视图仅显示简短的 `Error editing file` 行;完整消息出现在您使用 `Ctrl+O` 打开的会话记录视图中。被阻止的命令在其命令输出中打印它。
4513* 如果同一文件上的块重复,路径可能通过包含 `..` 的已提交符号链接运行,例如 `docs/current -> ../README.md`;要求 Claude 通过其真实路径而不是通过链接编辑目标文件4577* 如果同一文件上的阻止重复出现,路径可能通过包含 `..` 的已提交符号链接运行,例如 `docs/current -> ../README.md`;要求 Claude 通过其真实路径而不是通过链接编辑目标文件
4514 4578
4515<h3 id="write-or-command-blocked-because-the-path-names-a-network-location">4579<h3 id="write-or-command-blocked-because-the-path-names-a-network-location">
4516 写入或命令被阻止,因为路径命名网络位置4580 写入或命令被阻止,因为路径命名网络位置
4550* 要有意对主检出采取行动,在会话外的终端中自己运行该命令4614* 要有意对主检出采取行动,在会话外的终端中自己运行该命令
4551 4615
4552<h3 id="this-session-has-no-saved-transcript">4616<h3 id="this-session-has-no-saved-transcript">
4553 此会话没有保存的记录4617 此会话没有保存的会话记录
4554</h3>4618</h3>
4555 4619
4556您附加到一个停止的[后台会话](/docs/zh-CN/agent-view),该会话从另一个对话中用 `←` 或 `/background` 后台化,并在其第一个响应完成之前停止。在该第一个响应完成之前,对话仍然仅存在于后台化它的会话中,因此 `claude attach` 拒绝启动停止的会话,而不是在相同的会话 ID 下开始空白对话。消息以此会话的 `claude respawn` 命令结尾:4620您附加到一个停止的[后台会话](/docs/zh-CN/agent-view),该会话从另一个对话中用 `←` 或 `/background` 后台化,并在其第一个回复完成之前停止。在该第一个回复完成之前,对话仍然仅存在于后台化它的会话中,因此 `claude attach` 拒绝启动停止的会话,而不是在相同的会话 ID 下开始空白对话。消息以此会话的 `claude respawn` 命令结尾:
4557 4621
4558```text theme={null}4622```text theme={null}
4559This session has no saved transcript — it was stopped before its first response finished. If it was backgrounded from another conversation, that one is still intact; `claude respawn <id>` starts this one fresh.4623This session has no saved transcript — it was stopped before its first response finished. If it was backgrounded from another conversation, that one is still intact; `claude respawn <id>` starts this one fresh.
4560```4624```
4561 4625
4562在[代理视图](/docs/zh-CN/agent-view)中打开相同会话的行显示 `Press enter again to restart this session fresh` 在列表下方,在该行上第二次 `Enter` 使用空对话重启会话。在 v2.1.212 之前,打开该行显示拒绝消息,无法从代理视图重启。在 v2.1.211 之前,打开停止的会话无声地启动了该空白对话,并可能重新运行会话的原始提示。4626在 [Agent 视图](/docs/zh-CN/agent-view)中打开相同会话的行会在列表下方显示 `Press enter again to restart this session fresh`,在该行上第二次按 `Enter` 会使用空对话重启会话。在 v2.1.212 之前,打开该行显示拒绝消息,无法从 Agent 视图重启。在 v2.1.211 之前,打开停止的会话会无声地启动该空白对话,并可能重新运行会话的原始提示词。
4563 4627
4564**要做什么:**4628**要做什么:**
4565 4629
4566* 您后台化的对话是完整的:使用 [`claude --resume`](/docs/zh-CN/sessions) 恢复它或继续在其中工作4630* 您后台化的对话是完整的:使用 [`claude --resume`](/docs/zh-CN/sessions) 恢复它或继续在其中工作
4567* 要无论如何启动停止的会话,请使用消息中的 ID 运行 `claude respawn <id>`,或在代理视图中的其行上按 `Enter` 两次4631* 要无论如何启动停止的会话,请使用消息中的 ID 运行 `claude respawn <id>`,或在 Agent 视图中的其行上按 `Enter` 两次
4568* 如果会话确实完成了响应,您仍然在 v2.1.214 之前的版本上看到此拒绝,`~/.claude/projects` 中的不可读文件夹可能会使记录扫描错过保存的对话;更新到 v2.1.214 或更高版本,它在扫描期间容忍不可读的文件夹4632* 如果会话确实完成了回复,您仍然在 v2.1.214 之前的版本上看到此拒绝,`~/.claude/projects` 中的不可读文件夹可能会使会话记录扫描错过保存的对话;更新到 v2.1.214 或更高版本,它在扫描期间容忍不可读的文件夹
4569 4633
4570<h3 id="this-session-is-running-in-another-terminal">4634<h3 id="this-session-is-running-in-another-terminal">
4571 此会话在另一个终端中运行4635 此会话在另一个终端中运行
4572</h3>4636</h3>
4573 4637
4574您在[代理视图](/docs/zh-CN/agent-view)中打开了停止的会话的行,其保存的对话已在此机器上的另一个实时 Claude Code 进程中打开,因此 Claude Code 拒绝启动将写入相同记录的第二个进程。您看到的消息取决于[什么持有对话](/docs/zh-CN/agent-view#opening-a-session-says-the-conversation-is-already-open):4638您在 [Agent 视图](/docs/zh-CN/agent-view)中打开了停止的会话的行,其保存的对话已在此机器上的另一个实时 Claude Code 进程中打开,因此 Claude Code 拒绝启动将写入相同会话记录的第二个进程。您看到的消息取决于[什么持有对话](/docs/zh-CN/agent-view#opening-a-session-says-the-conversation-is-already-open):
4575 4639
4576```text theme={null}4640```text theme={null}
4577Can't open — this session is running in another terminal4641Can't open — this session is running in another terminal
4581* **`running in another terminal`**:终端持有对话,例如您使用 `claude --resume` 或 `/resume` 恢复它的终端。该行也显示 `Open in a terminal`。4645* **`running in another terminal`**:终端持有对话,例如您使用 `claude --resume` 或 `/resume` 恢复它的终端。该行也显示 `Open in a terminal`。
4582* **`already open in another running Claude session`**:另一个非交互式 Claude Code 进程持有它,例如相同对话的[后台会话](/docs/zh-CN/agent-view#the-supervisor-process)进程尚未退出。4646* **`already open in another running Claude session`**:另一个非交互式 Claude Code 进程持有它,例如相同对话的[后台会话](/docs/zh-CN/agent-view#the-supervisor-process)进程尚未退出。
4583 4647
4584Claude Code 保存您在打开行时键入的回复,并在会话下次启动时将其作为会话的下一个提示发送。4648Claude Code 保存您在打开行时键入的回复,并在会话下次启动时将其作为会话的下一个提示词发送。
4585 4649
4586**要做什么:**4650**要做什么:**
4587 4651
4593 此会话的保存对话不再在磁盘上4657 此会话的保存对话不再在磁盘上
4594</h3>4658</h3>
4595 4659
4596您打开了一个[后台会话](/docs/zh-CN/agent-view),该会话在后台服务关闭时结束,[记录清理](/docs/zh-CN/settings-reference#cleanupperioddays)随后删除了其保存的对话,例如在机器关闭数周后。通常打开这样的行会[恢复其保存的对话](/docs/zh-CN/agent-view#sessions-show-as-failed-after-shutdown)。没有什么可恢复的,Claude Code 拒绝而不是在不询问的情况下重新运行会话的原始提示:4660您打开了一个[后台会话](/docs/zh-CN/agent-view),该会话在后台服务关闭时结束,[会话记录清理](/docs/zh-CN/settings-reference#cleanupperioddays)随后删除了其保存的对话,例如在机器关闭数周后。通常打开这样的行会[恢复其保存的对话](/docs/zh-CN/agent-view#sessions-show-as-failed-after-shutdown)。没有什么可恢复的,Claude Code 拒绝而不是在不询问的情况下重新运行会话的原始提示词:
4597 4661
4598```text theme={null}4662```text theme={null}
4599This session's saved conversation is no longer on disk (it ended while the background service was off, and old transcripts are cleaned up), so there is nothing to resume. `claude rm 7c5dcf5d` deletes the row; `claude respawn 7c5dcf5d` runs its original prompt again instead.4663This session's saved conversation is no longer on disk (it ended while the background service was off, and old transcripts are cleaned up), so there is nothing to resume. `claude rm 7c5dcf5d` deletes the row; `claude respawn 7c5dcf5d` runs its original prompt again instead.
4600```4664```
4601 4665
4602`claude attach <id>` 打印此文本。在代理视图中,页脚更短,以 `ctrl+x deletes the row` 结尾。4666`claude attach <id>` 打印此文本。在 Agent 视图中,页脚更短,以 `ctrl+x deletes the row` 结尾。
4603 4667
4604**要做什么:**4668**要做什么:**
4605 4669
4606* 运行 `claude rm <id>` 删除该行。当[保留的情况](/docs/zh-CN/agent-view#what-deleting-a-session-removes)之一适用时,`claude rm` 保留该行和 worktree,并命名原因4670* 运行 `claude rm <id>` 删除该行。当[保留的情况](/docs/zh-CN/agent-view#what-deleting-a-session-removes)之一适用时,`claude rm` 保留该行和 worktree,并命名原因
4607* 要再次运行会话的原始提示作为新对话,请运行 `claude respawn <id>`4671* 要再次运行会话的原始提示词作为新对话,请运行 `claude respawn <id>`
4608 4672
4609在 v2.1.248 之前,打开这样的行会重新运行会话的原始提示,而不是拒绝,将数周前的任务拉回前景。4673在 v2.1.248 之前,打开这样的行会重新运行会话的原始提示词,而不是拒绝,将数周前的任务拉回前台。
4610 4674
4611<h3 id="worktree-has-commits-that-are-not-pushed-anywhere">4675<h3 id="worktree-has-commits-that-are-not-pushed-anywhere">
4612 Worktree 有未推送到任何地方的提交4676 Worktree 有未推送到任何地方的提交
4613</h3>4677</h3>
4614 4678
4615您尝试删除一个[后台会话](/docs/zh-CN/agent-view#what-deleting-a-session-removes),其 worktree 持有 Claude Code 无法确认保存在其他地方的提交。Claude Code 保留 worktree 和会话行,而不是销毁提交。`claude rm` 命名分支和未推送的提交,并说明如何继续:4679您尝试删除一个[后台会话](/docs/zh-CN/agent-view#what-deleting-a-session-removes),其 worktree 持有 Claude Code 无法确认保存在其他地方的提交。Claude Code 保留 worktree 和会话行,而不是在未查看的情况下销毁提交。`claude rm` 命名分支和未推送的提交,并说明如何继续:
4616 4680
4617```text theme={null}4681```text theme={null}
4618kept 7c5dcf5d — its worktree is still at "/home/you/project/.claude/worktrees/fix-login"4682kept 7c5dcf5d — its worktree is still at “/home/you/project/.claude/worktrees/fix-login”
4619 2 unpushed commits on "claude/fix-login": a1b2c3d "Fix login flow" and 1 more. They exist on no remote, so deleting the worktree would lose them.4683 2 unpushed commits on “claude/fix-login”: a1b2c3d “Fix login flow” and 1 more. They exist on no remote, so deleting the worktree would lose them.
4620 push them and run 'claude rm 7c5dcf5d' again, or discard the worktree and its commits: claude rm 7c5dcf5d --discard-unpushed a1b2c3d000000000000000000000000000000000@0123456789abcdef0123456789abcdef4684 push them and run 'claude rm 7c5dcf5d' again, or discard the worktree and its commits: claude rm 7c5dcf5d --discard-unpushed a1b2c3d000000000000000000000000000000000@0123456789abcdef0123456789abcdef
4621```4685```
4622 4686
4623当 Claude Code 无法总结提交时,详细行读取 `The worktree has unpushed commits`。在[代理视图](/docs/zh-CN/agent-view)中,会话的行显示 `not deleted` 和相同的原因。4687当 Claude Code 无法总结提交时,详细行读取 `The worktree has unpushed commits`。在 [Agent 视图](/docs/zh-CN/agent-view)中,会话的行显示 `not deleted` 和相同的原因。
4624 4688
4625远程上的提交不会阻止删除。本地副本中您的 `origin` 远程的默认分支上的提交也不会,只要该分支在您的主检出中检出,即存储库目录本身而不是 worktree。4689远程上的提交不会阻止删除。本地副本中您的 `origin` 远程的默认分支上的提交也不会,只要该分支在您的主检出中检出,即仓库目录本身而不是 worktree。
4626 4690
4627**要做什么:**4691**要做什么:**
4628 4692
4629* 要保留提交,推送 worktree 的分支,或将其合并到在主检出中检出的默认分支,然后再次删除会话4693* 要保留提交,推送 worktree 的分支,或将其合并到在主检出中检出的默认分支,然后再次删除会话
4630* 要丢弃提交,运行消息打印的 `claude rm <id> --discard-unpushed` 命令,或在代理视图中的会话行上再次按 `Ctrl+X`。这会删除会话和 worktree 以及其分支、未推送的提交和任何未提交的更改。如果 worktree 自拒绝以来获得了提交,Claude Code 再次保留它并显示更新的状态4694* 要丢弃提交,运行消息打印的 `claude rm <id> --discard-unpushed` 命令,或在 Agent 视图中的会话行上再次按 `Ctrl+X` 两次。这会删除会话和 worktree 以及其分支、未推送的提交和任何未提交的更改。如果 worktree 自拒绝以来获得了提交,Claude Code 再次保留它并显示更新的状态
4631* 当消息说 worktree 也由另一个完成的会话记录时,再次删除不会丢弃它:推送提交,然后再次删除会话4695* 当消息说 worktree 也由另一个完成的会话记录时,再次删除不会丢弃它:推送提交,然后再次删除会话
4632 4696
4633在 v2.1.268 之前,`claude rm` 将提交摘要放在 `kept` 行本身上。当 `claude rm` 无法总结提交时,`kept` 行读取 `worktree has commits that are not pushed anywhere` 代替摘要。4697在 v2.1.268 之前,`claude rm` 将提交摘要放在 `kept` 行本身上。当 `claude rm` 无法总结提交时,`kept` 行读取 `worktree has commits that are not pushed anywhere` 代替摘要。
4642 4706
4643每个[后台会话的](/docs/zh-CN/agent-view)终端在后台服务下的主机进程中运行,该进程在服务仍然持有其连接时死亡,因此无法到达会话。4707每个[后台会话的](/docs/zh-CN/agent-view)终端在后台服务下的主机进程中运行,该进程在服务仍然持有其连接时死亡,因此无法到达会话。
4644 4708
4645在 Linux 和 WSL 上,后台服务每隔几秒检查每个主机进程,当进程已退出但其与服务的连接从未关闭时标记会话失败,并在[代理视图](/docs/zh-CN/agent-view#read-session-state)中的其行上显示原因:4709在 Linux 和 WSL 上,后台服务每隔几秒检查每个主机进程,当进程已退出但其与服务的连接从未关闭时标记会话失败,并在 [Agent 视图](/docs/zh-CN/agent-view#read-session-state)中的其行上显示原因:
4646 4710
4647```text theme={null}4711```text theme={null}
4648terminal host process died — press Enter to restart4712terminal host process died — press Enter to restart
4656 4720
4657对话无论如何都被保存。4721对话无论如何都被保存。
4658 4722
4659运行[shell 命令](/docs/zh-CN/agent-view#run-a-shell-command)的行显示 `terminal host process died — its output is gone; the command was not run again`,`claude attach` 打印 `This command's terminal host process died — its output is gone and the command was not run again`。Claude Code 从不为您重新运行该命令。4723运行 [shell 命令](/docs/zh-CN/agent-view#run-a-shell-command)的行显示 `terminal host process died — its output is gone; the command was not run again`,`claude attach` 打印 `This command's terminal host process died — its output is gone and the command was not run again`。Claude Code 从不为您重新运行该命令。
4660 4724
4661**要做什么:**4725**要做什么:**
4662 4726
4663* 在代理视图中,在失败的行上按 `Enter`;会话在新的主机进程上重启,对话恢复4727* 在 Agent 视图中,在失败的行上按 `Enter`;会话在新的主机进程上重启,对话恢复
4664* 从 shell,再次运行 `claude attach <id>`。Claude Code 打印 `Session <id>'s terminal host died — restarting it on a fresh one…` 并重新打开会话4728* 从 shell,再次运行 `claude attach <id>`。Claude Code 打印 `Session <id>'s terminal host died — restarting it on a fresh one…` 并重新打开会话
4665* 您无法以这种方式重启 shell 命令行;再次分派命令以重新运行它4729* 您无法以这种方式重启 shell 命令行;再次分派命令以重新运行它
4666 4730
4672 4736
4673您打开了一个[后台会话](/docs/zh-CN/agent-view),后台服务接受了打开,但大约十秒钟内没有输出到达,因此 Claude Code 得出结论,中继会话终端的进程无法传递输出,并结束尝试而不是等待。4737您打开了一个[后台会话](/docs/zh-CN/agent-view),后台服务接受了打开,但大约十秒钟内没有输出到达,因此 Claude Code 得出结论,中继会话终端的进程无法传递输出,并结束尝试而不是等待。
4674 4738
4675在代理视图中,Claude Code 在页脚中提供重启:4739在 Agent 视图中,Claude Code 在页脚中提供重启:
4676 4740
4677```text theme={null}4741```text theme={null}
4678Press enter again to restart this session — it isn't responding (its conversation is saved and resumes).4742Press enter again to restart this session — it isn't responding (its conversation is saved and resumes).
4684Couldn't attach to <id> — Session isn't responding — `claude stop <id>`, then `claude attach <id>` restarts it (the conversation is saved).4748Couldn't attach to <id> — Session isn't responding — `claude stop <id>`, then `claude attach <id>` restarts it (the conversation is saved).
4685```4749```
4686 4750
4687Claude Code 从不为您重启运行[shell 命令](/docs/zh-CN/agent-view#run-a-shell-command)的行,因为重启会再次运行该命令。4751Claude Code 从不为您重启运行 [shell 命令](/docs/zh-CN/agent-view#run-a-shell-command)的行,因为重启会再次运行该命令。
4688 4752
4689**要做什么:**4753**要做什么:**
4690 4754
4691* 在代理视图中,在同一行上再次按 `Enter`。Claude Code 停止无响应的进程并重启会话,对话恢复。没有第二次按下就不会停止任何东西4755* 在 Agent 视图中,在同一行上再次按 `Enter`。Claude Code 停止无响应的进程并重启会话,对话恢复。没有第二次按下就不会停止任何东西
4692* 从 shell,运行 `claude stop <id>`,然后 `claude attach <id>`4756* 从 shell,运行 `claude stop <id>`,然后 `claude attach <id>`
4693* 对于 shell 命令行,在代理视图中按 `Ctrl+X` 或运行 `claude stop <id>` 停止它;再次分派命令以重新运行它4757* 对于 shell 命令行,在 Agent 视图中按 `Ctrl+X` 或运行 `claude stop <id>` 停止它;再次分派命令以重新运行它
4694 4758
4695<h3 id="session-was-stopped-while-the-respawn-was-in-flight">4759<h3 id="session-was-stopped-while-the-respawn-was-in-flight">
4696 会话在 respawn 进行中时被停止4760 会话在 respawn 进行中时被停止
4702Session <id> was stopped while the respawn was in flight4766Session <id> was stopped while the respawn was in flight
4703```4767```
4704 4768
4705打开您刚刚分派的会话,当其进程仍在启动时,等待进程。在 v2.1.246 之前,在那一刻打开它可能会停止它并显示此消息。4769打开您刚刚分派的会话,当其进程仍在启动时,会改为等待进程。在 v2.1.246 之前,在那一刻打开它可能会停止它并显示此消息。
4706 4770
4707**要做什么:**4771**要做什么:**
4708 4772
4709* 如果您没有停止会话,在代理视图中再次打开其行或运行 `claude respawn <id>` 重启它4773* 如果您没有停止会话,在 Agent 视图中再次打开其行或运行 `claude respawn <id>` 重启它
4710* 如果您自己停止了它,没有什么剩下要做的:会话保持停止4774* 如果您自己停止了它,没有什么剩下要做的:会话保持停止
4711 4775
4712<h3 id="session-agent-no-longer-available">4776<h3 id="session-agent-no-longer-available">
4713 会话代理不再可用4777 会话 Agent 不再可用
4714</h3>4778</h3>
4715 4779
4716您恢复了一个正在运行[自定义代理](/docs/zh-CN/sub-agents#invoke-subagents-explicitly)的会话,使用 `--agent` 或 `agent` 设置启动,Claude Code 没有找到具有该名称的代理。它首先搜索会话的原始目录,当您[信任该工作区](/docs/zh-CN/permissions#project-allow-rules-and-workspace-trust)时,然后搜索您恢复的目录。会话仍然恢复,但使用默认工具,因此代理的工具限制不再适用:4780您恢复了一个正在运行[自定义 Agent](/docs/zh-CN/sub-agents#invoke-subagents-explicitly) 的会话,该会话使用 `--agent` 或 `agent` 设置启动,Claude Code 没有找到具有该名称的 Agent。它首先搜索会话的原始目录(当您已[信任该工作区](/docs/zh-CN/permissions#project-allow-rules-and-workspace-trust)时),然后搜索您恢复的目录。会话仍然恢复,但使用默认工具,因此 Agent 的工具限制不再适用:
4717 4781
4718```text theme={null}4782```text theme={null}
4719This session was running agent 'code-reviewer', which is no longer available (no agent by that name in /home/you/project). Continuing with the default tools and system prompt — the agent's tool restrictions no longer apply. To restore it, re-create the agent, or resume with an explicit --agent <name>.4783This session was running agent 'code-reviewer', which is no longer available (no agent by that name in /home/you/project). Continuing with the default tools and system prompt — the agent's tool restrictions no longer apply. To restore it, re-create the agent, or resume with an explicit --agent <name>.
4720```4784```
4721 4785
4722警告仅命名 Claude Code 搜索的目录,它出现在恢复的对话中,无论您唤醒[后台会话](/docs/zh-CN/agent-view)、运行 `/resume` 或 `claude --resume`,还是在[非交互式模式](/docs/zh-CN/headless)中恢复,它也发送到 stderr。使用 `--input-format stream-json` 的会话不显示它,因为 Agent SDK 在启动后提供代理。4786警告仅命名 Claude Code 搜索的目录,它出现在恢复的对话中,无论您唤醒[后台会话](/docs/zh-CN/agent-view)、运行 `/resume` 或 `claude --resume`,还是在[非交互模式](/docs/zh-CN/headless)中恢复,在非交互模式中它也会发送到 stderr。使用 `--input-format stream-json` 的会话不显示它,因为 Agent SDK 在启动后提供 Agent。
4723 4787
4724Claude Code 不保存回退到会话,因此警告在每次恢复时重复,直到您采取行动。内置 `claude` 代理不触发警告,因为回退到默认工具集对它没有改变。在 v2.1.216 之前,Claude Code 无声地继续作为默认代理,查找仅覆盖您恢复的目录,因此项目范围的代理在从另一个目录恢复时丢失。4788Claude Code 不会将回退保存到会话,因此警告在每次恢复时重复,直到您采取行动。内置 `claude` Agent 不触发警告,因为回退到默认工具集对它没有改变。在 v2.1.216 之前,Claude Code 无声地继续作为默认 Agent,查找仅覆盖您恢复的目录,因此项目范围的 Agent 在从另一个目录恢复时丢失。
4725 4789
4726**要做什么:**4790**要做什么:**
4727 4791
4728* 在会话的项目中的 `.claude/agents/<name>.md` 或个人代理的 `~/.claude/agents/<name>.md` 重新创建代理文件,然后再次恢复4792* 在会话的项目中的 `.claude/agents/<name>.md` 或个人 Agent 的 `~/.claude/agents/<name>.md` 重新创建 Agent 文件,然后再次恢复
4729* 或使用 `--agent <name>` 恢复,命名确实存在的代理,以改为作为该代理运行会话4793* 或使用 `--agent <name>` 恢复,命名确实存在的 Agent,以改为作为该 Agent 运行会话
4730* 如果代理是项目范围的,您还没有信任会话的原始目录,在那里运行一次 Claude Code,接受信任对话,然后再次恢复4794* 如果 Agent 是项目范围的,您还没有信任会话的原始目录,在那里运行一次 Claude Code,接受信任对话框,然后再次恢复
4731 4795
4732<h3 id="claude_code_process_wrapper-launcher-errors">4796<h3 id="claude_code_process_wrapper-launcher-errors">
4733 CLAUDE\_CODE\_PROCESS\_WRAPPER 启动器错误4797 CLAUDE\_CODE\_PROCESS\_WRAPPER 启动器错误
4739CLAUDE_CODE_PROCESS_WRAPPER: launcher `/opt/corp/launcher` is not an executable regular file4803CLAUDE_CODE_PROCESS_WRAPPER: launcher `/opt/corp/launcher` is not an executable regular file
4740```4804```
4741 4805
4742启动但在用 Claude Code 替换自己之前退出的启动器会使其启动的会话失败,会话在代理视图中的行报告启动器 `must exec, not daemonize`,后跟启动器打印的任何内容。无法启动或到达后台服务的会话因启动器报告启动器问题作为 `Couldn't reach the background service (...)` 内的原因。4806启动但在用 Claude Code 替换自己之前退出的启动器会使其启动的会话失败,会话在 Agent 视图中的行报告启动器 `must exec, not daemonize`,后跟启动器打印的任何内容。因启动器而无法启动或到达后台服务的会话会将启动器问题作为 `Couldn't reach the background service (...)` 内的原因报告。
4743 4807
4744**要做什么:**4808**要做什么:**
4745 4809
4746* 将变量设置为以调用 `exec "$@"` 结尾的可执行文件的绝对路径。有关完整合同,请参阅[启动器合同](/docs/zh-CN/corporate-launcher#the-launcher-contract)4810* 将变量设置为以调用 `exec "$@"` 结尾的可执行文件的绝对路径。有关完整合同,请参阅[启动器合同](/docs/zh-CN/corporate-launcher#the-launcher-contract)
4747* 检查 `/status`,它在其 Self-exec 条目中显示解析的启动命令,并在运行的后台服务不匹配时警告,或从 shell 运行 `claude daemon status`4811* 检查 `/status`,它在其 Self-exec 条目中显示解析的启动命令,并在运行的后台服务不匹配时警告,或从 shell 运行 `claude daemon status`
4748* 在[设置](/docs/zh-CN/corporate-launcher#set-up-the-launcher)的 `env` 块中修复值后,使用 `claude daemon stop --any` 重启后台服务,以便下一次分派启动一个包装的4812* 在[设置](/docs/zh-CN/corporate-launcher#set-up-the-launcher)的 `env` 块中修复值后,使用 `claude daemon stop --any` 重启后台服务,以便下一次分派启动一个包装的后台服务
4749 4813
4750<h3 id="eunknown-when-starting-a-background-session">4814<h3 id="eunknown-when-starting-a-background-session">
4751 启动后台会话时 EUNKNOWN4815 启动后台会话时 EUNKNOWN
4767 4831
4768**要做什么:**4832**要做什么:**
4769 4833
4770* 如果消息读取 `Couldn't start the session`,升级到 v2.1.212 或更高版本。在早期版本上,您也可以在单独的终端中首先运行 `claude daemon run`,然后再次启动后台会话。该命令在终端的前景中运行后台服务,因此服务仅在该终端保持打开时持续。4834* 如果消息读取 `Couldn't start the session`,升级到 v2.1.212 或更高版本。在早期版本上,您也可以在单独的终端中首先运行 `claude daemon run`,然后再次启动后台会话。该命令在终端的前台运行后台服务,因此服务仅在该终端保持打开时持续。
4771* 如果 npm 安装正在替换二进制文件,等待它完成,然后再次启动后台会话4835* 如果 npm 安装正在替换二进制文件,等待它完成,然后再次启动后台会话
4772* 如果错误在 v2.1.212 或更高版本上出现,而没有 npm 安装运行,请要求您的 Windows 管理员在限制策略中允许 Claude Code 可执行文件4836* 如果错误在 v2.1.212 或更高版本上出现,而没有 npm 安装运行,请向您的 Windows 管理员确认是否有限制策略阻止了 Claude Code 可执行文件
4773* 如果关闭终端时后台服务停止,Claude Code 在没有 PowerShell 的情况下启动了它。安装 PowerShell 7,或要求您的管理员解除对 PowerShell 的阻止,以便服务可以超越终端。4837* 如果关闭终端时后台服务停止,Claude Code 在没有 PowerShell 的情况下启动了它。安装 PowerShell 7,或要求您的管理员解除对 PowerShell 的阻止,以便服务可以超越终端。
4774 4838
4775<h3 id="eacces-when-starting-a-background-session">4839<h3 id="eacces-when-starting-a-background-session">
4776 启动后台会话时 EACCES4840 启动后台会话时 EACCES
4777</h3>4841</h3>
4778 4842
4779Claude Code 无法运行其自己的二进制文件来启动[后台服务](/docs/zh-CN/agent-view#the-supervisor-process),该服务托管后台会话。在 npm 安装上,这通常意味着 `npm install -g @anthropic-ai/claude-code` 在那一刻替换二进制文件,无论您运行它还是[自动更新程序](/docs/zh-CN/setup#auto-updates)运行。当您从[代理视图](/docs/zh-CN/agent-view)打开会话时,错误出现:4843Claude Code 无法运行其自己的二进制文件来启动[后台服务](/docs/zh-CN/agent-view#the-supervisor-process),该服务托管后台会话。在 npm 安装上,这通常意味着 `npm install -g @anthropic-ai/claude-code` 在那一刻替换二进制文件,无论您运行它还是[自动更新程序](/docs/zh-CN/setup#auto-updates)运行。当您从 [Agent 视图](/docs/zh-CN/agent-view)打开会话时,错误出现:
4780 4844
4781```text theme={null}4845```text theme={null}
4782Couldn't start the background service — spawn background service: EACCES: permission denied, posix_spawn '/usr/local/lib/node_modules/@anthropic-ai/claude-code/bin/claude'4846Couldn't start the background service — spawn background service: EACCES: permission denied, posix_spawn '/usr/local/lib/node_modules/@anthropic-ai/claude-code/bin/claude'
4795**要做什么:**4859**要做什么:**
4796 4860
4797* 等待几秒钟,然后打开会话或再次分派。当消息说 Claude Code 正在更新时,在更新完成后重试。4861* 等待几秒钟,然后打开会话或再次分派。当消息说 Claude Code 正在更新时,在更新完成后重试。
4798* 如果错误在没有 npm 安装运行时持续,您的用户无法运行已安装的二进制文件。检查其权限及其目录的,或重新安装 Claude Code。4862* 如果错误在没有 npm 安装运行时持续,您的用户无法运行已安装的二进制文件。检查其权限及其目录的权限,或重新安装 Claude Code。
4799 4863
4800<h3 id="background-service-exited-before-it-became-reachable">4864<h3 id="background-service-exited-before-it-became-reachable">
4801 后台服务在变得可达之前退出4865 后台服务在变得可达之前退出
4802</h3>4866</h3>
4803 4867
4804Claude Code 启动的进程作为[后台服务](/docs/zh-CN/agent-view#the-supervisor-process)在变得可达之前退出,因此 Claude Code 无法打开您的会话。当服务在退出前打印错误时,括号中的原因给出退出代码或信号以及服务打印的第一行,它命名停止它的内容:4868Claude Code 作为[后台服务](/docs/zh-CN/agent-view#the-supervisor-process)启动的进程在接受连接之前退出,因此 Claude Code 无法打开您的会话。当服务在退出前打印错误时,括号中的原因给出退出码或信号以及服务打印的第一行,它命名停止它的内容:
4805 4869
4806```text theme={null}4870```text theme={null}
4807Couldn't reach the background service (background service exited before it became reachable (exit code N): <the service's first error line>) — run 'claude daemon status'4871Couldn't reach the background service (background service exited before it became reachable (exit code N): <the service's first error line>) — run 'claude daemon status'
4808```4872```
4809 4873
4810当您从[代理视图](/docs/zh-CN/agent-view)打开会话时,相同的原因跟随 `Couldn't start the background service —`。当服务在退出前没有打印任何内容时,消息说 `nothing on stderr`。4874当您从 [Agent 视图](/docs/zh-CN/agent-view)打开会话时,相同的原因跟随 `Couldn't start the background service —`。当服务在退出前没有打印任何内容时,消息说 `nothing on stderr`。
4811 4875
4812Claude Code 使用服务的错误行报告失败。在 v2.1.246 之前,失败仅在 45 秒等待后显示,作为 `background service did not become reachable within 45s`,没有服务的错误行。4876Claude Code 使用服务的错误行报告失败。在 v2.1.246 之前,失败仅在 45 秒等待后显示,作为 `background service did not become reachable within 45s`,没有服务的错误行。
4813 4877
4814两个引用的原因有已知的原因:4878两个引用的原因有已知的成因:
4815 4879
4816* `Error: claude native binary not installed.`:npm 安装在那一刻替换 Claude Code 二进制文件,因此服务运行了 npm 的占位符。在安装完成后重试;如果没有安装运行的行持续,[完成 npm 安装](/docs/zh-CN/troubleshoot-install#native-binary-not-found-after-npm-install)。在 v2.1.257 之前,macOS npm 自更新在安装窗口期间的每次启动时产生此失败。4880* `Error: claude native binary not installed.`:npm 安装在那一刻替换 Claude Code 二进制文件,因此服务运行了 npm 的占位符。在安装完成后重试;如果在没有安装运行时该行持续出现,[完成 npm 安装](/docs/zh-CN/troubleshoot-install#native-binary-not-found-after-npm-install)。在 v2.1.257 之前,macOS npm 自更新在安装窗口期间的每次启动时产生此失败。
4817* 在 Windows 上,`nothing on stderr` 和退出代码 1,每次启动:`daemon.lock` 命名一个 Claude Code 既无法发信号也无法证明已消失的进程,因此每个新服务得出结论另一个持有锁并退出。Claude Code 可以证明其编写者已消失的锁会自动替换,不会产生此失败。当失败在每次启动时重复时,删除 `~/.claude/daemon.lock`,然后打开会话或再次分派。在 v2.1.257 之前,这样的锁阻止了每次启动,直到您删除了文件。4881* 在 Windows 上,`nothing on stderr` 和退出码 1,每次启动:`daemon.lock` 命名一个 Claude Code 既无法发信号也无法证明已消失的进程,因此每个新服务得出结论另一个持有锁并退出。Claude Code 可以证明其编写者已消失的锁会自动替换,不会产生此失败。当失败在每次启动时重复时,删除 `~/.claude/daemon.lock`,然后打开会话或再次分派。在 v2.1.257 之前,这样的锁阻止了每次启动,直到您删除了文件。
4818 4882
4819**要做什么:**4883**要做什么:**
4820 4884
4825 启动后台会话时工作目录不再存在4889 启动后台会话时工作目录不再存在
4826</h3>4890</h3>
4827 4891
4828您尝试在不再存在的目录中启动[后台会话](/docs/zh-CN/agent-view)。Claude Code 不启动会话,消息命名缺失的目录:4892您启动[后台会话](/docs/zh-CN/agent-view)所在的目录在会话启动期间被删除。Claude Code 不启动会话,消息命名缺失的目录:
4829 4893
4830```text theme={null}4894```text theme={null}
4831Couldn't start a background session (working directory no longer exists or is not accessible: /tmp/demo)4895Couldn't start a background session (working directory no longer exists or is not accessible: /tmp/demo)
4832```4896```
4833 4897
4834在 v2.1.257 之前,会话似乎启动,然后在代理视图中显示为具有相同原因的失败行。4898在 v2.1.257 之前,会话似乎启动,然后在 Agent 视图中显示为具有相同原因的失败行。
4835 4899
4836在 v2.1.281 之前,当您启动会话之前目录已经消失时,此消息也出现。该情况报告[`could not be resolved on disk`](#workspace-not-trusted-when-dispatching-a-background-session)。4900在 v2.1.281 之前,当您启动会话之前目录已经消失时,此消息也出现。该情况报告 [`could not be resolved on disk`](#workspace-not-trusted-when-dispatching-a-background-session)。
4837 4901
4838**要做什么:**4902**要做什么:**
4839 4903
4843 分派后台会话时工作区不受信任4907 分派后台会话时工作区不受信任
4844</h3>4908</h3>
4845 4909
4846您在未[信任](/docs/zh-CN/permissions#project-allow-rules-and-workspace-trust)的目录中启动或重启[后台会话](/docs/zh-CN/agent-view),工作区信任对话无法出现以询问您。Claude Code 不启动会话:4910您在未[信任](/docs/zh-CN/permissions#project-allow-rules-and-workspace-trust)的目录中启动或重启[后台会话](/docs/zh-CN/agent-view),工作区信任对话框无法出现以询问您。Claude Code 不启动会话:
4847 4911
4848```text theme={null}4912```text theme={null}
4849Workspace not trusted. Run `claude` in /path/to/project once and accept the trust prompt, then retry.4913Workspace not trusted. Run `claude` in /path/to/project once and accept the trust prompt, then retry.
4850```4914```
4851 4915
4852从会话自己的目录中的终端,相同的命令显示信任对话,并在您接受后启动会话。此消息出现在无法显示对话的地方,例如在脚本中,或当您从不同于其自己的目录重启会话时。4916从会话自己的目录中的终端,相同的命令会改为显示信任对话框,并在您接受后启动会话。此消息出现在无法显示对话框的地方,例如在脚本中,或当您从不同于其自己的目录重启会话时。
4853 4917
4854两个变体命名不同的原因:4918两个变体命名不同的原因:
4855 4919
4856* **`The home directory is trusted one session at a time`**:会话的目录是您的主目录。Claude Code 从不保存主目录的信任,因此在早期会话中接受那里的对话不计数。4920* **`The home directory is trusted one session at a time`**:会话的目录是您的主目录。Claude Code 从不保存主目录的信任,因此在早期会话中在那里接受对话框不计数。
4857* **`<path> could not be resolved on disk`**:Claude Code 无法在磁盘上找到会话的目录。4921* **`<path> could not be resolved on disk`**:Claude Code 无法在磁盘上找到会话的目录。
4858 4922
4923在 v2.1.286 之前,在 Windows 上,如果某个您已信任的目录的信任记录是以不同字母大小写的路径保存的,此消息也可能在该目录中出现。请更新到 v2.1.286 或更高版本。
4924
4859**要做什么:**4925**要做什么:**
4860 4926
4861* 在消息命名的目录中运行 `claude` 并接受信任对话,然后再次运行该命令4927* 在消息命名的目录中运行 `claude` 并接受信任对话框,然后再次运行该命令
4862* 对于主目录消息,从您的主目录中的终端运行该命令,以便对话可以出现,或改为从项目目录启动会话4928* 对于主目录消息,从您的主目录中的终端运行该命令,以便对话框可以出现,或改为从项目目录启动会话
4863* 对于 `could not be resolved on disk` 消息,重新创建目录,或从存在的目录启动新会话4929* 对于 `could not be resolved on disk` 消息,重新创建目录,或从存在的目录启动新会话
4864 4930
4865<h2 id="wrapper-and-ide-errors">4931<h2 id="wrapper-and-ide-errors">