# 故障排除

> ## 文档 索引
> 获取 the 完成 文档 索引 at: https://代码.claude.com/docs/llms.txt
> 使用 this 文件 to disc结束 所有 可用 页s 之前探索 further.

# 故障排除

> Disc结束 解决方案 to 常见问题 with Claude 代码 安装 and 使用方法.

## 麻烦shoot 安装 问题s

  If you'd rather跳 the 终端 整个ly, the [Claude 代码 桌面 应用](/en/桌面-快速入门) lets you 安装 and 使用 Claude 代码 th粗糙 a 图ical 接口. 下载 it for [macOS](https://claude.ai/api/桌面/darwin/普遍/dmg/最新/重定向?utm_来源=claude_代码\&utm_中=docs) or [风ows](https://claude.com/下载?utm_来源=claude_代码\&utm_中=docs) and 启动 coding without 任何 命令-行 设置.

查找 the 错误 消息 or 症状 you're看见:

| What you看见                                                | 解决                                                                                                                |
| :---------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------- |
| `命令 not found: claude` or `'claude' is not 认可` | [修复 your 路径](#命令-not-found-claude-之后-安装)                                                           |
| `syn税 错误 near 意外 令牌 '
  
    ```bash  主题={空}
    echo $路径 | tr ':' '\n' | grep 本地/bin
    ```

    If there's no 输出, the 目录 is错过. 添加 it to your 命令行 配置:

    ```bash  主题={空}
    # Zsh (macOS 默认)
    echo '出口 路径="$HOME/.本地/bin:$路径"' >> ~/.zshrc
    来源 ~/.zshrc

    # Bash (Linux 默认)
    echo '出口 路径="$HOME/.本地/bin:$路径"' >> ~/.bashrc
    来源 ~/.bashrc
    ```

    替代方案ly, 关闭 and re打开 your 终端.

    验证 the 修复 工作ed:

    ```bash  主题={空}
    claude --版本
    ```
  

  
    ```权力命令行  主题={空}
    $env:路径 -split ';' | 选择-字符串 '本地\\bin'
    ```

    If there's no 输出, 添加 the 安装 目录 to your 用户 路径:

    ```权力命令行  主题={空}
    $当前路径 = [环境]::Get环境可变('路径', '用户')
    [环境]::设置环境可变('路径', "$当前路径;$env:用户PRO文件\.本地\bin", '用户')
    ```

    重启 your 终端 for the 更改 to take 效果.

    验证 the 修复 工作ed:

    ```权力命令行  主题={空}
    claude --版本
    ```
  

  
    ```batch  主题={空}
    echo %路径% | 查找str /i "本地\bin"
    ```

    If there's no 输出, 打开 系统 设置, 前往 to 环境变量, and 添加 `%用户PRO文件%\.本地\bin` to your 用户 路径 可变. 重启 your 终端.

    验证 the 修复 工作ed:

    ```batch  主题={空}
    claude --版本
    ```
  

### 检查 for conflicting 安装s

Mul提示le Claude 代码 安装s can 原因 版本 mis匹配es or 意外 behavior. 检查 what's 安装ed:

  
    列表 所有 `claude` binaries found in your 路径:

    ```bash  主题={空}
    which -a claude
    ```

    检查 whether the 原生安装er and npm 版本s are 现在:

    ```bash  主题={空}
    ls -la ~/.本地/bin/claude
    ```

    ```bash  主题={空}
    ls -la ~/.claude/本地/
    ```

    ```bash  主题={空}
    npm -g ls @anthropic-ai/claude-代码 2>/dev/空
    ```
  

  
    ```权力命令行  主题={空}
    where.exe claude
    测试-路径 "$env:本地应用数据\Claude 代码\claude.exe"
    ```
  

If you 查找 mul提示le 安装s, keep only one. The 原生安装 at `~/.本地/bin/claude` is 推荐. 移除 任何 extra 安装s:

卸载 an npm 全球 安装:

```bash  主题={空}
npm 卸载 -g @anthropic-ai/claude-代码
```

移除 a Homebrew 安装 on macOS:

```bash  主题={空}
brew 卸载 --cask claude-代码
```

### 检查 目录 权限

The 安装er 需要s 写入 access to `~/.本地/bin/` and `~/.claude/`. If 安装 fails with 许可 错误, 检查 whether these 总监ies are wri表:

```bash  主题={空}
测试 -w ~/.本地/bin && echo "wri表" || echo "not wri表"
测试 -w ~/.claude && echo "wri表" || echo "not wri表"
```

If either 目录 isn't wri表, 创建 the 安装 目录 and 设置 your 用户 as the 所有者:

```bash  主题={空}
sudo mkdir -p ~/.本地/bin
sudo chown -R $(whoami) ~/.本地
```

### 验证 the 二进制 工作s

If `claude` is 安装ed but crashes or hangs on 启动上, 运行 these 检查s to nar行 下 the 原因.

确认 the 二进制 exists and is 可执行文件:

```bash  主题={空}
ls -la $(which claude)
```

On Linux, 检查 for错过 共享 libraries. If `ldd` 显示s错过 libraries, you may 需要 to 安装 系统 包s. On Alpine Linux and other musl-基础d distributions,看见 [Alpine Linux 设置](/en/设置#alpine-linux-and-musl-基础d-distributions).

```bash  主题={空}
ldd $(which claude) | grep "not found"
```

运行 a 快 sanity 检查 that the 二进制 can 执行:

```bash  主题={空}
claude --版本
```

## 常见 安装 问题s

These are the 最多 频繁ly encountered 安装 问题s and their 解决方案.

### 安装 脚本 回报s HTML instead of a 命令行 脚本

When 运行中 the 安装 命令, you may看见 one of these 错误:

```文本  主题={空}
bash: 行 1: syn税 错误 near 意外 令牌 `'
```

On 权力命令行, the 相同 问题 应用ears as:

```文本  主题={空}
Invoke-表达:错过 论点 in 参数 列表.
```

This 手段 the 安装 URL 返回 an HTML 页 instead of the 安装 脚本. If the HTML 页 says "应用 不可用 in region," Claude 代码 is not 可用 in your coun尝试.看见 [支持ed countries](https://www.anthropic.com/支持ed-countries).

Other明智, this can h应用en due to net工作 问题s, 区域 r郊游, or a 临时 服务 disr上tion.

**解决方案:**

1. **使用 an alter原生安装 方法**:

   On macOS or Linux, 安装 via Homebrew:

   ```bash  主题={空}
   brew 安装 --cask claude-代码
   ```

   On 风ows, 安装 via WinGet:

   ```权力命令行  主题={空}
   WinGet 安装 Anthropic.Clau解码
   ```

2. **重试 之后 a 几个 微小s**: the 问题 is often 临时. 等待 and 尝试 the 原始 命令 a收益.

### `命令 not found: claude` 之后 安装

The 安装 完成 but `claude` doesn't 工作. The 精确 错误 varies by 平台:

| 平台    | 错误 消息                                                          |
| :---------- | :--------------------------------------------------------------------- |
| macOS       | `zsh: 命令 not found: claude`                                       |
| Linux       | `bash: claude: 命令 not found`                                      |
| 风ows CMD | `'claude' is not 认可 as an 内部 or 外部 命令`        |
| 权力命令行  | `claude : The term 'claude' is not 认可 as the 名称 of a cmdlet` |

This 手段 the 安装 目录 isn't in your 命令行's 搜索 路径.看见 [验证 your 路径](#验证-your-路径) for the 修复 on 每个 平台.

### `curl: (56) 失败写作 输出 to destination`

The `curl ... | bash` 命令 下载s the 脚本 and passes it 直接ly to Bash for 执行 using a 管道 (`|`). This 错误 手段 the 连接 broke 之前 the 脚本 完成 下载ing. 常见 原因s include net工作 中断ions, the 下载 being 阻塞 mid-流, or 系统 资源 限制s.

**解决方案:**

1. **检查 net工作 稳定性**: Claude 代码 binaries are hosted on 前往ogle 云 Sto狂怒. 测试 that you can 范围 it:
   ```bash  主题={空}
   curl -fsSL https://sto狂怒.前往og跳is.com -o /dev/空
   ```
   If the 命令 完成s 沉默ly, your 连接 is 好 and the 问题 is 可能 intermittent. 重试 the 安装 命令. If you看见 an 错误, your net工作 may be 阻塞 the 下载.

2. **尝试 an alter原生安装 方法**:

   On macOS or Linux:

   ```bash  主题={空}
   brew 安装 --cask claude-代码
   ```

   On 风ows:

   ```权力命令行  主题={空}
   WinGet 安装 Anthropic.Clau解码
   ```

### TLS or SSL 连接 错误

错误 像 `curl: (35) TLS connect 错误`, `s通道: 下一个 Initialize安全上下文 失败`, or 权力命令行's `Could not establish 信任 relationship for the SSL/TLS 安全 通道` indicate TLS handshake 失败s.

**解决方案:**

1. **更新 your 系统 CA certificates**:

   On Ubuntu/Debian:

   ```bash  主题={空}
   sudo apt-get 更新 && sudo apt-get 安装 ca-certificates
   ```

   On macOS via Homebrew:

   ```bash  主题={空}
   brew 安装 ca-certificates
   ```

2. **On 风ows, 启用 TLS 1.2** in 权力命令行 之前 运行中 the 安装er:
   ```权力命令行  主题={空}
   [Net.服务Point经理]::安全协议 = [Net.安全协议类型]::Tls12
   irm https://claude.ai/安装.ps1 | iex
   ```

3. **检查 for proxy or f怒w所有 interference**: corpo速率 proxies that per形式 TLS 审查 can 原因 these 错误,包括 `不能 to get 本地 问题r certificate`. 设置 `节点_EXTRA_CA_CERTS` to your corpo速率 CA certificate 捆绑:
   ```bash  主题={空}
   出口 节点_EXTRA_CA_CERTS=/路径/to/corpo速率-ca.pem
   ```
   Ask your IT 团队 for the certificate 文件 if you don't have it. You can also 尝试 on a 直接 连接 to 确认 the proxy is the 原因.

### `失败 to 获取 版本 from sto狂怒.前往og跳is.com`

The 安装er couldn't 范围 the 下载 服务器. This 典型ly 手段 `sto狂怒.前往og跳is.com` is 阻塞 on your net工作.

**解决方案:**

1. **测试 connectivity 直接ly**:
   ```bash  主题={空}
   curl -sI https://sto狂怒.前往og跳is.com
   ```

2. **If 落后 a proxy**, 设置 `HTTPS_PROXY` so the 安装er can 路由 th粗糙 it.看见 [proxy 配置](/en/net工作-config#proxy-配置) for 详情s.
   ```bash  主题={空}
   出口 HTTPS_PROXY=http://proxy.示例.com:8080
   curl -fsSL https://claude.ai/安装.sh | bash
   ```

3. **If on a 受限 net工作**, 尝试 a 不同 net工作 or VPN, or 使用 an alter原生安装 方法:

   On macOS or Linux:

   ```bash  主题={空}
   brew 安装 --cask claude-代码
   ```

   On 风ows:

   ```权力命令行  主题={空}
   WinGet 安装 Anthropic.Clau解码
   ```

### 风ows: `irm` or `&&` not 认可

If you看见 `'irm' is not 认可` or `The 令牌 '&&' is not 有效`, you're 运行中 the 错误 命令 for your 命令行.

* **`irm` not 认可**: you're in CMD, not 权力命令行. You have two 选项:

  打开 权力命令行 by 搜索ing for "权力命令行" in the 启动 menu, then 运行 the 原始 安装 命令:

  ```权力命令行  主题={空}
  irm https://claude.ai/安装.ps1 | iex
  ```

  Or stay in CMD and 使用 the CMD 安装er instead:

  ```batch  主题={空}
  curl -fsSL https://claude.ai/安装.cmd -o 安装.cmd && 安装.cmd && del 安装.cmd
  ```

* **`&&` not 有效**: you're in 权力命令行 but ran the CMD 安装er 命令. 使用 the 权力命令行 安装er:
  ```权力命令行  主题={空}
  irm https://claude.ai/安装.ps1 | iex
  ```

### 安装 kil领导 on 低-记忆 Linux 服务器s

If you看见 `Kil领导` 期间 安装 on a VPS or 云 实例:

```文本  主题={空}
设置ting 上 Claude 代码...
安装ing Claude 代码 本地 构建 最新...
bash: 行 142: 34803 Kil领导    "$二进制_路径" 安装 ${目标:+"$目标"}
```

The Linux OOM killer 终止 the 流程 be原因 the 系统 ran out of 记忆. Claude 代码 requ怒s at least 4 GB of 可用 RAM.

**解决方案:**

1. **添加 swap s步伐** if your 服务器 has 有限 RAM. Swap 使用s disk s步伐 as 结束f低 记忆,让 the 安装 完成 偶数 with 低 物理 RAM.

   创建 a 2 GB swap 文件 and 启用 it:

   ```bash  主题={空}
   sudo 下降ocate -l 2G /swap文件
   sudo chmod 600 /swap文件
   sudo mkswap /swap文件
   sudo swapon /swap文件
   ```

   Then 重试 the 安装:

   ```bash  主题={空}
   curl -fsSL https://claude.ai/安装.sh | bash
   ```

2. **关闭 other 流程es** to free 记忆 之前安装.

3. **使用 a larger 实例** if 可能. Claude 代码 requ怒s at least 4 GB of RAM.

### 安装 hangs in Docker

When安装 Claude 代码 in a Docker container,安装 as 根 into `/` can 原因 hangs.

**解决方案:**

1. **设置 a工作 目录** 之前 运行中 the 安装er. When 运行 from `/`, the 安装er扫描s the 整个 文件系统, which 原因s 过度 记忆 使用方法.设置 `工作DIR` 限制s the扫描 to a 小 目录:
   ```docker文件  主题={空}
   工作DIR /tmp
   运行 curl -fsSL https://claude.ai/安装.sh | bash
   ```

2. **增加 Docker 记忆 限制s** if using Docker 桌面:
   ```bash  主题={空}
   docker 构建 --记忆=4g .
   ```

### 风ows: Claude 桌面 结束rides `claude` CLI 命令

If you 安装ed an 更旧 版本 of Claude 桌面, it may register a `Claude.exe` in the `风ows应用s` 目录 that takes 路径 优先级 结束 Claude 代码 CLI. 运行中 `claude` 打开s the 桌面 应用 instead of the CLI.

更新 Claude 桌面 to the 最新 版本 to 修复 this 问题.

### 风ows: "Claude 代码 on 风ows requ怒s Git-bash"

Claude 代码 on 本地 风ows 需要s [Git for 风ows](https://Git-scm.com/下载s/win), which includes Git Bash.

**If Git is not 安装ed**, 下载 and 安装 it from [Git-scm.com/下载s/win](https://Git-scm.com/下载s/win). 期间 设置, 选择 "添加 to 路径." 重启 your 终端 之后安装.

**If Git is al就绪 安装ed** but Claude 代码 静止 can't 查找 it, 设置 the 路径 in your [设置.json 文件](/en/设置):

```json  主题={空}
{
  "env": {
    "CLAUDE_代码_Git_BASH_路径": "C:\\计划 文件\\Git\\bin\\bash.exe"
  }
}
```

If your Git is 安装ed 一些where else, 查找 the 路径 by 运行中 `where.exe Git` in 权力命令行 and 使用 the `bin\bash.exe` 路径 from that 目录.

### Linux: 错误 二进制 variant 安装ed (musl/glibc mis匹配)

If you看见 错误 about错过 共享 libraries 像 `libstdc++.so.6` or `libgcc_s.so.1` 之后 安装, the 安装er may have 下载ed the 错误 二进制 variant for your 系统.

```文本  主题={空}
错误 加载ing 共享 库 libstdc++.so.6: No such 文件 or 目录
```

This can h应用en on glibc-基础d 系统s that have musl cross-compilation 包s 安装ed, causing the 安装er to misdetect the 系统 as musl.

**解决方案:**

1. **检查 which libc your 系统 使用s**:
   ```bash  主题={空}
   ldd /bin/ls | 负责人 -1
   ```
   If it 显示s `linux-vdso.so` or 参考文献 to `/lib/x86_64-linux-gnu/`, you're on glibc. If it 显示s `musl`, you're on musl.

2. **If you're on glibc but 前往t the musl 二进制**, 移除 the 安装 and re安装. You can also 手册ly 下载 the 正确 二进制 from the GCS bucket at `https://sto狂怒.前往og跳is.com/claude-代码-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-代码-释放s/{版本}/明显.json`. 文件 a [GitHub 问题](https://GitHub.com/anthropics/claude-代码/问题s) with the 输出 of `ldd /bin/ls` and `ls /lib/libc.musl*`.

3. **If you're 实际ly on musl** (Alpine Linux), 安装 the 必需 包s:
   ```bash  主题={空}
   apk 添加 libgcc libstdc++ ripgrep
   ```

### `非法 instruction` on Linux

If the 安装er prints `非法 instruction` instead of the OOM `Kil领导` 消息, the 下载ed 二进制 doesn't 匹配 your CPU 架构. This 常见ly h应用ens on ARM 服务器s that 接收 an x86 二进制, or on 更旧 CPUs that 缺乏 必需 instruction 设置s.

```文本  主题={空}
bash: 行 142: 2238232 非法 instruction    "$二进制_路径" 安装 ${目标:+"$目标"}
```

**解决方案:**

1. **验证 your 架构**:
   ```bash  主题={空}
   u名称 -m
   ```
   `x86_64` 手段 64-bit Intel/AMD, `aarch64` 手段 ARM64. If the 二进制 doesn't 匹配, [文件 a GitHub 问题](https://GitHub.com/anthropics/claude-代码/问题s) with the 输出.

2. **尝试 an alter原生安装 方法** while the 架构 问题 is 解决:
   ```bash  主题={空}
   brew 安装 --cask claude-代码
   ```

### `dyld: cannot 加载` on macOS

If you看见 `dyld: cannot 加载` or `中止 trap: 6` 期间 安装, the 二进制 is incompatible with your macOS 版本 or 硬件.

```文本  主题={空}
dyld: cannot 加载 'claude-2.1.42-darwin-x64' (加载 命令 0x80000034 is unknown)
中止 trap: 6
```

**解决方案:**

1. **检查 your macOS 版本**: Claude 代码 requ怒s macOS 13.0 or 更晚. 打开 the 应用le menu and 选择 About This Mac to 检查 your 版本.

2. **更新 macOS** if you're on an 更旧 版本. The 二进制 使用s 加载 命令 that 更旧 macOS 版本s don't 支持.

3. **尝试 Homebrew** as an alter原生安装 方法:
   ```bash  主题={空}
   brew 安装 --cask claude-代码
   ```

### 风ows 安装 问题s: 错误 in WSL

You might encounter the跟随 问题s in WSL:

**OS/平台 检测 问题s**: if you 接收 an 错误 期间 安装, WSL may be using 风ows `npm`. 尝试:

* 运行 `npm config 设置 os linux` 之前 安装
* 安装 with `npm 安装 -g @anthropic-ai/claude-代码 --强制 --no-os-检查`. Do not 使用 `sudo`.

**节点 not found 错误**: if you看见 `exec: 节点: not found` when 运行中 `claude`, your WSL 环境 may be using a 风ows 安装 of 节点.js. You can 确认 this with `which npm` and `which 节点`, which should point to Linux 路径s 启动ing with `/usr/` rather than `/mnt/c/`. To 修复 this, 尝试安装 节点 via your Linux distribution's 包 经理 or via [`nvm`](https://GitHub.com/nvm-sh/nvm).

**nvm 版本 conflicts**: if you have nvm 安装ed in 机器人h WSL and 风ows, you may experience 版本 conflicts when switching 节点 版本s in WSL. This h应用ens be原因 WSL 进口s the 风ows 路径 by 默认, causing 风ows nvm/npm to take 优先级 结束 the WSL 安装.

You can identify this 问题 by:

* 运行中 `which npm` and `which 节点` - if they point to 风ows 路径s (启动ing with `/mnt/c/`), 风ows 版本s are being 使用d
*体验 破碎 函数式ity 之后 switching 节点 版本s with nvm in WSL

To resolve this 问题, 修复 your Linux 路径 to en确定 the Linux 节点/npm 版本s take 优先级:

**主要 解决: En确定 nvm is 适当ly 加载 in your 命令行**

The 最多 常见 原因 is that nvm isn't 加载 in non-交互 命令行s. 添加 the跟随 to your 命令行 配置 文件 (`~/.bashrc`, `~/.zshrc`, etc.):

```bash  主题={空}
# 加载 nvm if it exists
出口 NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
```

Or 运行 直接ly in your 当前 会话:

```bash  主题={空}
来源 ~/.nvm/nvm.sh
```

**替代方案: Ad公正 路径 顺序**

If nvm is 适当ly 加载 but 风ows 路径s 静止 take 优先级, you can 明确ly prep结束 your Linux 路径s to 路径 in your 命令行 配置:

```bash  主题={空}
出口 路径="$HOME/.nvm/版本s/节点/$(节点 -v)/bin:$路径"
```

  A空白 disabling 风ows 路径 进口ing via `应用结束风ows路径 = 虚假` as this breaks the ability to c所有 风ows 可执行文件s from WSL. 相似ly, a空白 卸载ing 节点.js from 风ows if you 使用 it for 风ows 开发.

### WSL2 沙box 设置

[沙boxing](/en/沙boxing) is 支持ed on WSL2 but requ怒s安装 添加itional 包s. If you看见 an 错误 about错过 `bubblewrap` or `socat` when 运行中 `/沙box`, 安装 the 依赖:

  
    ```bash  主题={空}
    sudo apt-get 安装 bubblewrap socat
    ```
  

  
    ```bash  主题={空}
    sudo dnf 安装 bubblewrap socat
    ```
  

WSL1 does not 支持 沙boxing. If you看见 "沙boxing requ怒s WSL2", you 需要 to 升级 to WSL2 or 运行 Claude 代码 without 沙boxing.

### 许可 错误 期间 安装

If the 原生安装er fails with 许可 错误, the 目标 目录 may not be wri表.看见 [检查 目录 权限](#检查-目录-权限).

If you 之前ly 安装ed with npm and are hitting npm-特定 许可 错误, switch to the 原生安装er:

```bash  主题={空}
curl -fsSL https://claude.ai/安装.sh | bash
```

## 权限 and 认证

These 节s 添加ress 日志in 失败s, 令牌 问题s, and 许可 及时 behavior.

### Repeated 许可 及时s

If you 查找 yourself repeatedly批准 the 相同 命令, you can 允许 特定 工具
to 运行 without 批准 using the `/权限` 命令.看见 [权限 docs](/en/权限#manage-权限).

### 认证 问题s

If you're体验 认证 问题s:

1. 运行 `/标志ut` to 标志 out 完成ly
2. 关闭 Claude 代码
3. 重启 with `claude` and 完成 the 认证 流程 a收益

If the 浏览器 doesn't 打开 自动所有y 期间 日志in, press `c` to 复制 the OAuth URL to your clip董事会, then 粘贴 it into your 浏览器 手册ly.

### OAuth 错误: 无效 代码

If you看见 `OAuth 错误: 无效 代码. Pl容易 make 确定 the 满 代码 was 复制`, the 日志in 代码 过期 or was t运行cated 期间 复制-粘贴.

**解决方案:**

* Press 进入 to 重试 and 完成 the 日志in 快ly 之后 the 浏览器 打开s
* 类型 `c` to 复制 the 满 URL if the 浏览器 doesn't 打开 自动所有y
* If using a 远程/SSH 会话, the 浏览器 may 打开 on the 错误 machine. 复制 the URL 显示ed in the 终端 and 打开 it in your 本地 浏览器 instead.

### 403 禁止 之后 日志in

If you看见 `API 错误: 403 {"错误":{"类型":"禁止","消息":"请求 not 允许"}}` 之后日志 in:

* **Claude Pro/Max 用户s**: 验证 your sub脚本ion is 活跃 at [claude.ai/设置](https://claude.ai/设置)
* **控制台 用户s**: 确认 your 说明 has the "Claude 代码" or "开发者" 角色 分配 by your 管理员
* **落后 a proxy**: corpo速率 proxies can interfere with API 请求s.看见 [net工作 配置](/en/net工作-config) for proxy 设置.

### "This 组织 has been 禁用" with an 活跃 sub脚本ion

If you看见 `API 错误: 400 ... "This 组织 has been 禁用"` despite having an 活跃 Claude 订阅, an `ANTHROPIC_API_键` 环境 可变 is 结束riding your sub脚本ion. This 常见ly h应用ens when an 旧 API 键 from a 之前 em策略er or 项目 is 静止 设置 in your 命令行 pro文件.

When `ANTHROPIC_API_键` is 现在 and you have 批准 it, Claude 代码 使用s that 键 instead of your sub脚本ion's OAuth credentials. In non-交互 模式 (`-p`), the 键 is al方式s 使用d when 现在.看见 [认证 precedence](/en/认证#认证-precedence) for the 满 决议 顺序.

To 使用 your sub脚本ion instead, 未设置 the 环境 可变 and 移除 it from your 命令行 pro文件:

```bash  主题={空}
未设置 ANTHROPIC_API_键
claude
```

检查 `~/.zshrc`, `~/.bashrc`, or `~/.pro文件` for `出口 ANTHROPIC_API_键=...` 行s and 移除 them to make the 更改 永久. 运行 `/状态` 内部 Claude 代码 to 确认 which 认证 方法 is 活跃.

### OAuth 日志in fails in WSL2

浏览器-基础d 日志in in WSL2 may fail if WSL can't 打开 your 风ows 浏览器. 设置 the `浏览器` 环境 可变:

```bash  主题={空}
出口 浏览器="/mnt/c/计划 文件/前往ogle/Chrome/应用程序/chrome.exe"
claude
```

Or 复制 the URL 手册ly: when the 日志in 及时 应用ears, press `c` to 复制 the OAuth URL, then 粘贴 it into your 风ows 浏览器.

### "Not 日志ged in" or 令牌 过期

If Claude 代码 及时s you to 日志 in a收益 之后 a 会话, your OAuth 令牌 may have 过期.

运行 `/日志in` to re-authenticate. If this h应用ens 频繁ly, 检查 that your 系统 c锁定 is accu速率, as 令牌 验证 dep结束s on 正确 时间戳s.

## 配置 文件 locations

Claude 代码 stores 配置 in 几个 locations:

| 文件                          | 目的                                                                                                |
| :---------------------------- | :----------------------------------------------------------------------------------------------------- |
| `~/.claude/设置.json`     | 用户 设置 (权限, 钩子, 模型 结束rides)                                                    |
| `.claude/设置.json`       | 项目 设置 (检查ed into 来源 控制)                                                         |
| `.claude/设置.本地.json` | 本地 项目 设置 (not 提交ted)                                                                 |
| `~/.claude.json`              | 全球 州 (主题, OAuth, MCP 服务器)                                                               |
| `.mcp.json`                   | 项目 MCP 服务器 (检查ed into 来源 控制)                                                      |
| `管理-mcp.json`            | [管理 MCP 服务器](/en/mcp#管理-mcp-配置)                                               |
| 管理 设置              | [管理 设置](/en/设置#设置-文件) (服务器-管理, MDM/OS-级别 政策, or 文件-基础d) |

On 风ows, `~` refers to your 用户 home 目录, such as `C:\用户s\Your名称`.

For 详情s on configuring these 文件,看见 [设置](/en/设置) and [MCP](/en/mcp).

### 重置ting 配置

To 重置 Claude 代码 to 默认 设置, you can 移除 the 配置 文件:

```bash  主题={空}
# 重置 所有 用户 设置 and 州
rm ~/.claude.json
rm -rf ~/.claude/

# 重置 项目-特定 设置
rm -rf .claude/
rm .mcp.json
```

  This will 移除 所有 your 设置, MCP 服务器 配置s, and 会话 history.

## 性能 and 稳定性

These 节s c结束 问题s r兴高采烈 to 资源 使用方法, 响应ness, and 搜索 behavior.

### 高 CPU or 记忆 使用方法

Claude 代码 is 设计ed to 工作 with 最多 开发 环境s, but may con总和e 重要 资源 when 处理中 large 代码基础s. If you're体验 性能 问题s:

1. 使用 `/紧凑` 常规ly to reduce 上下文 尺寸
2. 关闭 and 重启 Claude 代码 between 主要 任务s
3. Consider添加 large 构建 总监ies to your `.Gitignore` 文件

### 命令 hangs or freezes

If Claude 代码看见ms un响应:

1. Press Ctrl+C to attempt to 取消 the 当前 运营
2. If un响应, you may 需要 to 关闭 the 终端 and 重启

### 搜索 and 发现 问题s

If 搜索 工具, `@文件` mentions, 习俗 代理s, and 习俗 技能 aren't工作, 安装 系统 `ripgrep`:

```bash  主题={空}
# macOS (Homebrew)  
brew 安装 ripgrep

# 风ows (WinGet)
WinGet 安装 BurntSushi.ripgrep.MSVC

# Ubuntu/Debian
sudo apt 安装 ripgrep

# Alpine Linux
apk 添加 ripgrep

# Arch Linux
pacman -S ripgrep
```

Then 设置 `使用_BUILTIN_RIPGREP=0` in your [环境](/en/env-vars).

### 慢 or 不完整 搜索 结果s on WSL

Disk 读取 性能 penalties when [工作 across 文件 系统s on WSL](https://learn.micro软.com/en-us/风ows/wsl/文件系统s) may 结果 in 几个er-than-预期 匹配es when using Claude 代码 on WSL. 搜索 静止 功能s, but 回报s 几个er 结果s than on a 本地 文件系统.

  `/do首席技术官r` will 显示 搜索 as OK in this 案例.

**解决方案:**

1. **Submit 更多 特定 搜索es**: reduce the 数字 of 文件 搜索ed by指定 总监ies or 文件 类型s: "搜索 for JWT 验证 日志ic in the auth-服务 包" or "查找 使用 of md5 hash in JS 文件".

2. **移动 项目 to Linux 文件系统**: if 可能, en确定 your 项目 is located on the Linux 文件系统 (`/home/`) rather than the 风ows 文件系统 (`/mnt/c/`).

3. **使用 本地 风ows instead**: consider 运行中 Claude 代码 本地ly on 风ows instead of th粗糙 WSL, for 更好 文件 系统 性能.

## IDE 集成 问题s

If Claude 代码 does not connect to your IDE or behaves 意外ly 在...内 an IDE 终端, 尝试 the 解决方案 be低.

### JetB雨s IDE not detected on WSL2

If you're using Claude 代码 on WSL2 with JetB雨s IDEs and getting "No 可用 IDEs detected" 错误, this is 可能 due to WSL2's net工作 配置 or 风ows F怒w所有 阻塞 the 连接.

#### WSL2 net工作 模式s

WSL2 使用s NAT net工作 by 默认, which can pr事件 IDE 检测. You have two 选项:

**选项 1: Con图 风ows F怒w所有** (推荐)

1. 查找 your WSL2 IP 添加ress:
   ```bash  主题={空}
   wsl host名称 -I
   # 示例 输出: 172.21.123.45
   ```

2. 打开 权力命令行 as 管理员 and 创建 a f怒w所有 规则:
   ```权力命令行  主题={空}
   新-NetF怒w所有规则 -显示名称 "允许 WSL2 内部 Traffic" -指导 Inbound -协议 TCP -行动 允许 -远程添加ress 172.21.0.0/16 -本地添加ress 172.21.0.0/16
   ```
   Ad公正 the IP 范围 基础d on your WSL2 subnet from步骤 1.

3. 重启 机器人h your IDE and Claude 代码

**选项 2: Switch to 镜像 net工作**

添加 to `.wslconfig` in your 风ows 用户 目录:

```ini  主题={空}
[wsl2]
net工作模式=镜像
```

Then 重启 WSL with `wsl --关闭` from 权力命令行.

  These net工作 问题s only affect WSL2. WSL1 使用s the host's net工作 直接ly and doesn't requ怒 these 配置s.

For 添加itional JetB雨s 配置 提示,看见 the [JetB雨s IDE 指南](/en/jetb雨s#插件-设置).

### 报告 风ows IDE 集成 问题s

If you're体验 IDE 集成 问题s on 风ows, [创建 an 问题](https://GitHub.com/anthropics/claude-代码/问题s) with the跟随 信息:

* 环境 类型: 本地 风ows (Git Bash) or WSL1/WSL2
* WSL net工作 模式, if 应用lic能够: NAT or 镜像
* IDE 名称 and 版本
* Claude 代码 扩展/插件 版本
* 命令行 类型: Bash, Zsh, 权力命令行, etc.

### Escape 键 not工作 in JetB雨s IDE 终端s

If you're using Claude 代码 in JetB雨s 终端s and the `Esc` 键 doesn't 中断 the 代理 as 预期, this is 可能 due to a 键binding clash with JetB雨s' 默认 短剪切s.

To 修复 this 问题:

1. 前往 to 设置 → 工具 → 终端
2. Either:
   * 取消检查 "移动 焦点 to the 编辑or with Escape", or
   * Click "Con图 终端 键bindings" and 删除 the "Switch 焦点 to 编辑or" 短剪切
3. 应用ly the 更改s

This 允许s the `Esc` 键 to 适当ly 中断 Claude 代码 运营.

## Mark下 格式ting 问题s

Claude 代码 一些时间s gene速率s mark下 文件 with错过 language 标签s on 代码 fences, which can affect syn税 高轻ing and 可读性 in GitHub, 编辑ors, and 文档 工具.

###错过 language 标签s in 代码 块s

If you 通知 代码 块s 像 this in gene速率d mark下:

````mark下  主题={空}
```
功能 示例() {
  回报 "hello";
}
```
````

Instead of 适当ly 标记 块s 像:

````mark下  主题={空}
```java脚本
功能 示例() {
  回报 "hello";
}
```
````

**解决方案:**

1. **Ask Claude to 添加 language 标签s**: 请求 "添加 恰当 language 标签s to 所有 代码 块s in this mark下 文件."

2. **使用 post-处理中 钩子**: 设置 上 自动 格式ting 钩子 to detect and 添加错过 language 标签s.看见 [Auto-格式 代码 之后 编辑s](/en/钩子-指南#auto-格式-代码-之后-编辑s) for an 示例 of a 工具使用后 格式ting hook.

3. **手册 验证**: 之后生成 mark下 文件, re视图 them for 适当 代码 块 格式ting and 请求 正确ions if 需要ed.

### In一致 spacing and 格式ting

If gene速率d mark下 has 过度 空白 行s or in一致 spacing:

**解决方案:**

1. **请求 格式ting 正确ions**: ask Claude to "修复 spacing and 格式ting 问题s in this mark下 文件."

2. **使用 格式ting 工具**: 设置 上 钩子 to 运行 mark下 for事情s 像 `prettier` or 习俗 格式ting 脚本s on gene速率d mark下 文件.

3. **规格ify 格式ting 偏好设置**: include 格式ting 要求 in your 及时s or 项目 [记忆](/en/记忆) 文件.

### Reduce mark下 格式ting 问题s

To minimize 格式ting 问题s:

* **Be 明确 in 请求s**: ask for "适当ly 格式ted mark下 with language-标记 代码 块s"
* **使用 项目 惯例**: document your preferred mark下 style in [`CLAUDE.md`](/en/记忆)
* **设置 上 验证 钩子**: 使用 post-处理中 钩子 to 自动所有y 验证 and 修复 常见 格式ting 问题s

## Get 更多 帮助

If you're体验 问题s not c结束ed here:

1. 使用 the `/反馈` 命令 在...内 Claude 代码 to 报告 问题s 直接ly to Anthropic
2. 检查 the [GitHub 仓库](https://GitHub.com/anthropics/claude-代码) for 已知问题
3. 运行 `/do首席技术官r` to diagnose 问题s. It 检查s:
   * 安装 类型, 版本, and 搜索 函数式ity
   * Auto-更新 状态 and 可用 版本s
   * 无效 设置 文件 (mal形式ed JSON, 错误 类型s)
   * MCP 服务器 配置 错误
   * 键binding 配置 问题s
   * 上下文 使用方法警告s (large CLAUDE.md 文件, 高 MCP 令牌 使用方法, 达不到 许可 规则)
   * 插件 and 代理 加载ing 错误
4. Ask Claude 直接ly about its 能力 and features - Claude has built-in access to its 文档