8 8
9本页面涵盖系统要求、特定平台安装详情、更新和卸载。有关首次会话的引导式演练,请参阅[快速入门](/docs/zh-CN/quickstart)。如果您从未使用过终端,请参阅[终端指南](/docs/zh-CN/terminal-guide)。9本页面涵盖系统要求、特定平台安装详情、更新和卸载。有关首次会话的引导式演练,请参阅[快速入门](/docs/zh-CN/quickstart)。如果您从未使用过终端,请参阅[终端指南](/docs/zh-CN/terminal-guide)。
10 10
11<h2 id="system-requirements">11## 系统要求
12 系统要求
13</h2>
14 12
15Claude Code 在以下平台和配置上运行:13Claude Code 在以下平台和配置上运行:
16 14
25* **Shell**:Bash、Zsh、PowerShell 或 CMD。23* **Shell**:Bash、Zsh、PowerShell 或 CMD。
26* **位置**:[Anthropic 支持的国家/地区](https://www.anthropic.com/supported-countries)24* **位置**:[Anthropic 支持的国家/地区](https://www.anthropic.com/supported-countries)
27 25
28<h3 id="additional-dependencies">26### 其他依赖项
29 其他依赖项
30</h3>
31 27
32* **ripgrep**:通常包含在 Claude Code 中。如果搜索失败,请参阅[搜索故障排除](/docs/zh-CN/troubleshooting#search-and-discovery-issues)。28* **ripgrep**:通常包含在 Claude Code 中。如果搜索失败,请参阅[搜索故障排除](/docs/zh-CN/troubleshooting#search-and-discovery-issues)。
33 29
34<h2 id="install-claude-code">30## 安装 Claude Code
35 安装 Claude Code
36</h2>
37 31
38<Tip>32> [!TIP]
39 更喜欢图形界面?[桌面应用](/docs/zh-CN/desktop-quickstart)让您无需使用终端即可使用 Claude Code。下载适用于 [macOS](https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect?utm_source=claude_code\&utm_medium=docs)、[Windows](https://claude.com/download?utm_source=claude_code\&utm_medium=docs) 或 [Linux](/docs/zh-CN/desktop-linux) 的版本。33>
40</Tip>34> 更喜欢图形界面?[桌面应用](/docs/zh-CN/desktop-quickstart)让您无需使用终端即可使用 Claude Code。下载适用于 [macOS](https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect?utm_source=claude_code\&utm_medium=docs)、[Windows](https://claude.com/download?utm_source=claude_code\&utm_medium=docs) 或 [Linux](/docs/zh-CN/desktop-linux) 的版本。
41 35
42要安装 Claude Code,请打开终端并运行适用于您的系统的命令。如果您之前没有使用过终端,[终端指南](/docs/zh-CN/terminal-guide)会展示如何打开终端并粘贴命令。36要安装 Claude Code,请打开终端并运行适用于您的系统的命令。如果您之前没有使用过终端,[终端指南](/docs/zh-CN/terminal-guide)会展示如何打开终端并粘贴命令。
43 37
44<Tabs>38**原生安装(推荐)**
45 <Tab title="原生安装(推荐)">
46 **macOS、Linux、WSL:**
47 39
48 ```bash theme={null}40**macOS、Linux、WSL:**
49 curl -fsSL https://claude.ai/install.sh | bash
50 ```
51 41
52 在 Windows 上,当您在 PowerShell 中时,您的提示符显示 `PS C:\`;当您在 CMD 中时,提示符显示 `C:\`(没有 `PS`)。42```bash theme={null}
43curl -fsSL https://claude.ai/install.sh | bash
44```
53 45
54 **Windows PowerShell:**46在 Windows 上,当您在 PowerShell 中时,您的提示符显示 `PS C:\`;当您在 CMD 中时,提示符显示 `C:\`(没有 `PS`)。
55 47
56 ```powershell theme={null}48**Windows PowerShell:**
57 irm https://claude.ai/install.ps1 | iex
58 ```
59 49
60 **Windows CMD:**50```powershell theme={null}
51irm https://claude.ai/install.ps1 | iex
52```
61 53
62 ```batch theme={null}54**Windows CMD:**
63 curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
64 ```
65 55
66 安装命令在下载 Claude Code 期间不会显示进度。安装程序完成后,打开一个新的终端窗口并运行 `claude --version`。正常的安装会打印一个版本号。如果您的 shell 显示找不到 `claude` 或无法识别,说明安装目录还不在您的 PATH 中:请参阅[修复您的 PATH](/docs/zh-CN/troubleshoot-install#command-not-found-claude-after-installation)。56```batch theme={null}
57curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
58```
67 59
68 如果您看到 `The token '&&' is not a valid statement separator`,说明您在 PowerShell 中,而不是 CMD。如果您看到 `'irm' is not recognized as an internal or external command`,说明您在 CMD 中,而不是 PowerShell。60安装命令在下载 Claude Code 期间不会显示进度。安装程序完成后,打开一个新的终端窗口并运行 `claude --version`。正常的安装会打印一个版本号。如果您的 shell 显示找不到 `claude` 或无法识别,说明安装目录还不在您的 PATH 中:请参阅[修复您的 PATH](/docs/zh-CN/troubleshoot-install#command-not-found-claude-after-installation)。
69 61
70 如果安装命令失败并显示 `syntax error near unexpected token '<'`、`403` 或其他任何错误,请参阅[排查安装问题](/docs/zh-CN/troubleshoot-install#find-your-error)以匹配错误并获得修复方案和替代安装方法。62如果您看到 `The token '&&' is not a valid statement separator`,说明您在 PowerShell 中,而不是 CMD。如果您看到 `'irm' is not recognized as an internal or external command`,说明您在 CMD 中,而不是 PowerShell。
71 63
72 建议在原生 Windows 上安装 [Git for Windows](https://git-scm.com/downloads/win),以便 Claude Code 可以使用 Bash 工具。如果未安装 Git for Windows,Claude Code 将使用 PowerShell 作为 shell 工具。WSL 设置不需要 Git for Windows。64如果安装命令失败并显示 `syntax error near unexpected token '<'`、`403` 或其他任何错误,请参阅[排查安装问题](/docs/zh-CN/troubleshoot-install#find-your-error)以匹配错误并获得修复方案和替代安装方法。
73 65
74 <Info>66建议在原生 Windows 上安装 [Git for Windows](https://git-scm.com/downloads/win),以便 Claude Code 可以使用 Bash 工具。如果未安装 Git for Windows,Claude Code 将使用 PowerShell 作为 shell 工具。WSL 设置不需要 Git for Windows。
75 原生安装会在后台自动更新,以保持您使用最新版本。
76 </Info>
77 </Tab>
78 67
79 <Tab title="Homebrew">68> [!NOTE]
80 ```bash theme={null}69>
81 brew install --cask claude-code70> 原生安装会在后台自动更新,以保持您使用最新版本。
82 ```
83 71
84 Homebrew 提供两个 casks。`claude-code` 跟踪稳定发布渠道,通常比最新版本晚约一周,并跳过有重大回归的版本。`claude-code@latest` 跟踪最新渠道,在新版本发布时立即接收。72**Homebrew**
85 73
86 <Info>74```bash theme={null}
87 Homebrew 安装不会自动更新。运行 `brew upgrade claude-code` 或 `brew upgrade claude-code@latest`(取决于您安装的 cask)以获取最新功能和安全修复。75brew install --cask claude-code
88 </Info>76```
89 </Tab>
90 77
91 <Tab title="WinGet">78Homebrew 提供两个 casks。`claude-code` 跟踪稳定发布渠道,通常比最新版本晚约一周,并跳过有重大回归的版本。`claude-code@latest` 跟踪最新渠道,在新版本发布时立即接收。
92 ```powershell theme={null}
93 winget install Anthropic.ClaudeCode
94 ```
95 79
96 <Info>80> [!NOTE]
97 WinGet 安装不会自动更新。定期运行 `winget upgrade Anthropic.ClaudeCode` 以获取最新功能和安全修复。81>
98 </Info>82> Homebrew 安装不会自动更新。运行 `brew upgrade claude-code` 或 `brew upgrade claude-code@latest`(取决于您安装的 cask)以获取最新功能和安全修复。
99 </Tab>83
100</Tabs>84**WinGet**
85
86```powershell theme={null}
87winget install Anthropic.ClaudeCode
88```
89
90> [!NOTE]
91>
92> WinGet 安装不会自动更新。定期运行 `winget upgrade Anthropic.ClaudeCode` 以获取最新功能和安全修复。
101 93
102您也可以在 Debian、Fedora、RHEL 和 Alpine 上使用 [apt、dnf 或 apk](/docs/zh-CN/setup#install-with-linux-package-managers) 进行安装。94您也可以在 Debian、Fedora、RHEL 和 Alpine 上使用 [apt、dnf 或 apk](/docs/zh-CN/setup#install-with-linux-package-managers) 进行安装。
103 95
111 103
112如果在安装过程中遇到任何问题,请参阅[故障排除安装和登录](/docs/zh-CN/troubleshoot-install)。104如果在安装过程中遇到任何问题,请参阅[故障排除安装和登录](/docs/zh-CN/troubleshoot-install)。
113 105
114<h3 id="set-up-on-windows">106### 在 Windows 上设置
115 在 Windows 上设置
116</h3>
117 107
118您可以在 Windows 上原生运行 Claude Code,也可以在 WSL 中运行。根据您的项目位置和所需的功能进行选择:108您可以在 Windows 上原生运行 Claude Code,也可以在 WSL 中运行。根据您的项目位置和所需的功能进行选择:
119 109
123| [WSL 2](#install-in-wsl) | WSL 2 已启用 | 支持 | Linux 工具链或沙箱命令执行 |113| [WSL 2](#install-in-wsl) | WSL 2 已启用 | 支持 | Linux 工具链或沙箱命令执行 |
124| [WSL 1](#install-in-wsl) | WSL 1 已启用 | 不支持 | 如果 WSL 2 不可用 |114| [WSL 1](#install-in-wsl) | WSL 1 已启用 | 不支持 | 如果 WSL 2 不可用 |
125 115
126<h4 id="install-on-native-windows">116#### 在原生 Windows 上安装
127 在原生 Windows 上安装
128</h4>
129 117
130从 PowerShell 或 CMD 运行[安装命令](#install-claude-code)。您无需以管理员身份运行。安装 [Git for Windows](https://git-scm.com/downloads/win) 是可选的。它提供 Git Bash,[Bash 工具](/docs/zh-CN/tools-reference#bash-tool-behavior)和 [Monitor 工具](/docs/zh-CN/tools-reference#monitor-tool)需要用到它。118从 PowerShell 或 CMD 运行[安装命令](#install-claude-code)。您无需以管理员身份运行。安装 [Git for Windows](https://git-scm.com/downloads/win) 是可选的。它提供 Git Bash,[Bash 工具](/docs/zh-CN/tools-reference#bash-tool-behavior)和 [Monitor 工具](/docs/zh-CN/tools-reference#monitor-tool)需要用到它。
131 119
146 134
147安装 Git for Windows 后,PowerShell 工具可与 Bash 一起使用:在 claude.ai 和 Console 账户上默认启用,在 Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 会话中使用 `CLAUDE_CODE_USE_POWERSHELL_TOOL=1` 启用。将其设置为 `0` 以关闭该工具。有关设置和限制,请参阅 [PowerShell 工具](/docs/zh-CN/tools-reference#powershell-tool)。135安装 Git for Windows 后,PowerShell 工具可与 Bash 一起使用:在 claude.ai 和 Console 账户上默认启用,在 Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 会话中使用 `CLAUDE_CODE_USE_POWERSHELL_TOOL=1` 启用。将其设置为 `0` 以关闭该工具。有关设置和限制,请参阅 [PowerShell 工具](/docs/zh-CN/tools-reference#powershell-tool)。
148 136
149<h4 id="install-in-wsl">137#### 在 WSL 中安装
150 在 WSL 中安装
151</h4>
152 138
153打开您的 WSL 发行版并按照[安装说明](#install-claude-code)运行 Linux 安装程序。您在 WSL 终端内安装和启动 `claude`,而不是从 PowerShell 或 CMD。139打开您的 WSL 发行版并按照[安装说明](#install-claude-code)运行 Linux 安装程序。您在 WSL 终端内安装和启动 `claude`,而不是从 PowerShell 或 CMD。
154 140
155<h3 id="alpine-linux-and-musl-based-distributions">141### Alpine Linux 和基于 musl 的发行版
156 Alpine Linux 和基于 musl 的发行版
157</h3>
158 142
159在 Alpine 和其他 musl/uClibc 基础发行版上安装 Claude Code 需要 `bash` 和 `curl` 用于安装命令,以及 `libgcc`、`libstdc++` 和 `ripgrep` 用于运行时。Alpine 默认不包含 `bash` 或 `curl`,因此在您安装它们之前,文档中的安装命令会失败并显示 `not found` 错误。使用您的发行版的包管理器安装这些包,然后设置 `USE_BUILTIN_RIPGREP=0`。143在 Alpine 和其他 musl/uClibc 基础发行版上安装 Claude Code 需要 `bash` 和 `curl` 用于安装命令,以及 `libgcc`、`libstdc++` 和 `ripgrep` 用于运行时。Alpine 默认不包含 `bash` 或 `curl`,因此在您安装它们之前,文档中的安装命令会失败并显示 `not found` 错误。使用您的发行版的包管理器安装这些包,然后设置 `USE_BUILTIN_RIPGREP=0`。
160 144
182}166}
183```167```
184 168
185<h2 id="verify-your-installation">169## 验证您的安装
186 验证您的安装
187</h2>
188 170
189安装后,确认 Claude Code 正常工作:171安装后,确认 Claude Code 正常工作:
190 172
204 186
205`claude doctor` 打印只读的安装和设置诊断信息,无需启动会话,包括安装健康状况、设置文件验证错误以及任何带有建议修复的警告。187`claude doctor` 打印只读的安装和设置诊断信息,无需启动会话,包括安装健康状况、设置文件验证错误以及任何带有建议修复的警告。
206 188
207<h2 id="authenticate">189## 身份验证
208 身份验证
209</h2>
210 190
211Claude Code 需要 Pro、Max、Team、Enterprise 或 Console 账户。免费的 claude.ai 计划不包括 Claude Code 访问权限。您也可以通过第三方 API 提供商(如 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock)、[Google Cloud's Agent Platform](/docs/zh-CN/google-vertex-ai) 或 [Microsoft Foundry](/docs/zh-CN/microsoft-foundry))使用 Claude Code。191Claude Code 需要 Pro、Max、Team、Enterprise 或 Console 账户。免费的 claude.ai 计划不包括 Claude Code 访问权限。您也可以通过第三方 API 提供商(如 [Amazon Bedrock](/docs/zh-CN/amazon-bedrock)、[Google Cloud's Agent Platform](/docs/zh-CN/google-vertex-ai) 或 [Microsoft Foundry](/docs/zh-CN/microsoft-foundry))使用 Claude Code。
212 192
213安装后,通过运行 `claude` 并按照浏览器提示登录。如果设置了 `ANTHROPIC_API_KEY` 环境变量,并且在 Claude Code 询问是否使用该密钥时您批准了它,Claude Code 将跳过登录提示。有关所有账户类型和团队设置选项,请参阅[身份验证](/docs/zh-CN/authentication)。193安装后,通过运行 `claude` 并按照浏览器提示登录。如果设置了 `ANTHROPIC_API_KEY` 环境变量,并且在 Claude Code 询问是否使用该密钥时您批准了它,Claude Code 将跳过登录提示。有关所有账户类型和团队设置选项,请参阅[身份验证](/docs/zh-CN/authentication)。
214 194
215<h2 id="update-claude-code">195## 更新 Claude Code
216 更新 Claude Code
217</h2>
218 196
219原生安装会在后台自动更新。您可以[配置发布渠道](#configure-release-channel)来控制您是立即接收更新还是按延迟的稳定计划接收更新,或者[完全禁用自动更新](#disable-auto-updates)。Homebrew、WinGet 和[Linux 包管理器](#install-with-linux-package-managers)安装默认需要手动更新。197原生安装会在后台自动更新。您可以[配置发布渠道](#configure-release-channel)来控制您是立即接收更新还是按延迟的稳定计划接收更新,或者[完全禁用自动更新](#disable-auto-updates)。Homebrew、WinGet 和[Linux 包管理器](#install-with-linux-package-managers)安装默认需要手动更新。
220 198
221<h3 id="auto-updates">199### 自动更新
222 自动更新
223</h3>
224 200
225Claude Code 在启动时和运行时定期检查更新。更新在后台下载和安装,然后在您下次启动 Claude Code 时生效。201Claude Code 在启动时和运行时定期检查更新。更新在后台下载和安装,然后在您下次启动 Claude Code 时生效。
226 202
234 210
235如果 npm 全局安装因为 npm 全局目录不可写而无法自动更新,Claude Code 会在启动时显示一次性通知,`claude doctor` 会列出可用的修复。有关详细信息,请参阅[安装期间的权限错误](/docs/zh-CN/troubleshoot-install#permission-errors-during-installation)。211如果 npm 全局安装因为 npm 全局目录不可写而无法自动更新,Claude Code 会在启动时显示一次性通知,`claude doctor` 会列出可用的修复。有关详细信息,请参阅[安装期间的权限错误](/docs/zh-CN/troubleshoot-install#permission-errors-during-installation)。
236 212
237<Note>213> [!NOTE]
238 Homebrew、WinGet、apt、dnf 和 apk 安装默认不会自动更新;请参阅下文以选择加入 Homebrew 和 WinGet。要手动升级 Homebrew,请运行 `brew upgrade claude-code` 或 `brew upgrade claude-code@latest`,具体取决于您安装的 cask。对于 WinGet,请运行 `winget upgrade Anthropic.ClaudeCode`。对于 Linux 包管理器,请参阅[使用 Linux 包管理器安装](#install-with-linux-package-managers)中的升级命令。214>
239 215> Homebrew、WinGet、apt、dnf 和 apk 安装默认不会自动更新;请参阅下文以选择加入 Homebrew 和 WinGet。要手动升级 Homebrew,请运行 `brew upgrade claude-code` 或 `brew upgrade claude-code@latest`,具体取决于您安装的 cask。对于 WinGet,请运行 `winget upgrade Anthropic.ClaudeCode`。对于 Linux 包管理器,请参阅[使用 Linux 包管理器安装](#install-with-linux-package-managers)中的升级命令。
240 要让 Claude Code 在 Homebrew 或 WinGet 上为您运行升级命令,请将 [`CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE`](/docs/zh-CN/env-vars) 设置为 `1`。Claude Code 随后会在新版本可用时在后台运行升级,并在成功时显示重启提示。升级仅针对 Claude Code 包,不会影响您已安装的其他软件。216>
217> 要让 Claude Code 在 Homebrew 或 WinGet 上为您运行升级命令,请将 [`CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE`](/docs/zh-CN/env-vars) 设置为 `1`。Claude Code 随后会在新版本可用时在后台运行升级,并在成功时显示重启提示。升级仅针对 Claude Code 包,不会影响您已安装的其他软件。
218>
219> 在 WinGet 上,当 Claude Code 运行时升级可能会失败,因为 Windows 会锁定可执行文件。在这种情况下,Claude Code 会改为显示手动命令。apt、dnf 和 apk 继续需要手动升级,因为这些命令需要提升的权限。
220>
221> **已知问题**:Claude Code 可能会在新版本在这些包管理器中可用之前通知您有更新。如果升级失败,请稍候后重试。
222>
223> Homebrew 在升级后会在磁盘上保留旧版本。定期运行 `brew cleanup` 以回收磁盘空间。
241 224
242 在 WinGet 上,当 Claude Code 运行时升级可能会失败,因为 Windows 会锁定可执行文件。在这种情况下,Claude Code 会改为显示手动命令。apt、dnf 和 apk 继续需要手动升级,因为这些命令需要提升的权限。225### 配置发布渠道
243
244 **已知问题**:Claude Code 可能会在新版本在这些包管理器中可用之前通知您有更新。如果升级失败,请稍候后重试。
245
246 Homebrew 在升级后会在磁盘上保留旧版本。定期运行 `brew cleanup` 以回收磁盘空间。
247</Note>
248
249<h3 id="configure-release-channel">
250 配置发布渠道
251</h3>
252 226
253使用 `autoUpdatesChannel` 设置控制 Claude Code 为自动更新和 `claude update` 遵循的发布渠道:227使用 `autoUpdatesChannel` 设置控制 Claude Code 为自动更新和 `claude update` 遵循的发布渠道:
254 228
271 245
272从 apt、dnf 和 apk 仓库进行的安装通过仓库而不是此设置来选择渠道。要切换渠道,请按照[使用 Linux 包管理器安装](#install-with-linux-package-managers)中的说明操作。246从 apt、dnf 和 apk 仓库进行的安装通过仓库而不是此设置来选择渠道。要切换渠道,请按照[使用 Linux 包管理器安装](#install-with-linux-package-managers)中的说明操作。
273 247
274<h3 id="pin-a-minimum-version">248### 固定最低版本
275 固定最低版本
276</h3>
277 249
278`minimumVersion` 设置建立了一个下限。后台自动更新和 `claude update` 拒绝安装低于此值的任何版本,因此如果您已经在较新的 `"latest"` 构建上,切换到 `"stable"` 渠道不会降级您。250`minimumVersion` 设置建立了一个下限。后台自动更新和 `claude update` 拒绝安装低于此值的任何版本,因此如果您已经在较新的 `"latest"` 构建上,切换到 `"stable"` 渠道不会降级您。
279 251
292 264
293`minimumVersion` 固定仅约束更新。要使 Claude Code 拒绝在版本范围外启动,请改为使用托管设置 `requiredMinimumVersion` 和 `requiredMaximumVersion`。更新也会遵守 `requiredMaximumVersion` 上限。请参阅 [`requiredMinimumVersion`](/docs/zh-CN/settings-reference#requiredminimumversion) 和 [`requiredMaximumVersion`](/docs/zh-CN/settings-reference#requiredmaximumversion)。265`minimumVersion` 固定仅约束更新。要使 Claude Code 拒绝在版本范围外启动,请改为使用托管设置 `requiredMinimumVersion` 和 `requiredMaximumVersion`。更新也会遵守 `requiredMaximumVersion` 上限。请参阅 [`requiredMinimumVersion`](/docs/zh-CN/settings-reference#requiredminimumversion) 和 [`requiredMaximumVersion`](/docs/zh-CN/settings-reference#requiredmaximumversion)。
294 266
295<h3 id="disable-auto-updates">267### 禁用自动更新
296 禁用自动更新
297</h3>
298 268
299在您的 [`settings.json`](/docs/zh-CN/settings-reference#all-settings) 文件的 `env` 键中将 `DISABLE_AUTOUPDATER` 设置为 `"1"`:269在您的 [`settings.json`](/docs/zh-CN/settings-reference#all-settings) 文件的 `env` 键中将 `DISABLE_AUTOUPDATER` 设置为 `"1"`:
300 270
310 280
311`DISABLE_AUTOUPDATER` 仅停止后台检查;`claude update` 和 `claude install` 仍然有效。要阻止所有更新路径(包括手动更新),请改为设置 [`DISABLE_UPDATES`](/docs/zh-CN/env-vars)。当您通过自己的渠道分发 Claude Code 并需要用户保持在您提供的版本上时,请使用此选项。281`DISABLE_AUTOUPDATER` 仅停止后台检查;`claude update` 和 `claude install` 仍然有效。要阻止所有更新路径(包括手动更新),请改为设置 [`DISABLE_UPDATES`](/docs/zh-CN/env-vars)。当您通过自己的渠道分发 Claude Code 并需要用户保持在您提供的版本上时,请使用此选项。
312 282
313<h3 id="update-manually">283### 手动更新
314 手动更新
315</h3>
316 284
317要立即应用更新而不等待下一次后台检查,请运行:285要立即应用更新而不等待下一次后台检查,请运行:
318 286
322 290
323当更新安装时,该命令报告 `Successfully updated from <old version> to version <new version>`。如果您已经在最新版本上,它报告 `Claude Code is up to date (<version>)`。由 Homebrew、WinGet 或 apk 管理的安装改为报告 `Claude is up to date!`。291当更新安装时,该命令报告 `Successfully updated from <old version> to version <new version>`。如果您已经在最新版本上,它报告 `Claude Code is up to date (<version>)`。由 Homebrew、WinGet 或 apk 管理的安装改为报告 `Claude is up to date!`。
324 292
325<h2 id="advanced-installation-options">293## 高级安装选项
326 高级安装选项
327</h2>
328 294
329这些选项用于版本固定、Linux 包管理器、npm、网络存储和验证二进制完整性。295这些选项用于版本固定、Linux 包管理器、npm、网络存储和验证二进制完整性。
330 296
331<h3 id="install-a-specific-version">297### 安装特定版本
332 安装特定版本
333</h3>
334 298
335原生安装程序接受特定版本号或发布渠道(`latest` 或 `stable`)。您在安装时选择的渠道将成为自动更新的默认值。有关更多信息,请参阅[配置发布渠道](#configure-release-channel)。299原生安装程序接受特定版本号或发布渠道(`latest` 或 `stable`)。您在安装时选择的渠道将成为自动更新的默认值。有关更多信息,请参阅[配置发布渠道](#configure-release-channel)。
336 300
337要安装最新版本(默认):301要安装最新版本(默认):
338 302
339<Tabs>303**macOS、Linux、WSL**
340 <Tab title="macOS、Linux、WSL">
341 ```bash theme={null}
342 curl -fsSL https://claude.ai/install.sh | bash
343 ```
344 </Tab>
345 304
346 <Tab title="Windows PowerShell">305```bash theme={null}
347 ```powershell theme={null}306curl -fsSL https://claude.ai/install.sh | bash
348 irm https://claude.ai/install.ps1 | iex307```
349 ```
350 </Tab>
351 308
352 <Tab title="Windows CMD">309**Windows PowerShell**
353 ```batch theme={null}310
354 curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd311```powershell theme={null}
355 ```312irm https://claude.ai/install.ps1 | iex
356 </Tab>313```
357</Tabs>314
315**Windows CMD**
316
317```batch theme={null}
318curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
319```
358 320
359要安装稳定版本:321要安装稳定版本:
360 322
361<Tabs>323**macOS、Linux、WSL**
362 <Tab title="macOS、Linux、WSL">
363 ```bash theme={null}
364 curl -fsSL https://claude.ai/install.sh | bash -s stable
365 ```
366 </Tab>
367 324
368 <Tab title="Windows PowerShell">325```bash theme={null}
369 ```powershell theme={null}326curl -fsSL https://claude.ai/install.sh | bash -s stable
370 & ([scriptblock]::Create((irm https://claude.ai/install.ps1))) stable327```
371 ```
372 </Tab>
373 328
374 <Tab title="Windows CMD">329**Windows PowerShell**
375 ```batch theme={null}330
376 curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd stable && del install.cmd331```powershell theme={null}
377 ```332& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) stable
378 </Tab>333```
379</Tabs>334
335**Windows CMD**
336
337```batch theme={null}
338curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd stable && del install.cmd
339```
380 340
381要安装特定版本号:341要安装特定版本号:
382 342
383<Tabs>343**macOS、Linux、WSL**
384 <Tab title="macOS、Linux、WSL">
385 ```bash theme={null}
386 curl -fsSL https://claude.ai/install.sh | bash -s 2.1.89
387 ```
388 </Tab>
389 344
390 <Tab title="Windows PowerShell">345```bash theme={null}
391 ```powershell theme={null}346curl -fsSL https://claude.ai/install.sh | bash -s 2.1.89
392 & ([scriptblock]::Create((irm https://claude.ai/install.ps1))) 2.1.89347```
393 ```
394 </Tab>
395 348
396 <Tab title="Windows CMD">349**Windows PowerShell**
397 ```batch theme={null}350
398 curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd 2.1.89 && del install.cmd351```powershell theme={null}
399 ```352& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) 2.1.89
400 </Tab>353```
401</Tabs>354
355**Windows CMD**
356
357```batch theme={null}
358curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd 2.1.89 && del install.cmd
359```
402 360
403要确认安装了哪个版本,请运行 `claude --version`:该命令打印您传递的确切版本,例如 `2.1.89 (Claude Code)`。361要确认安装了哪个版本,请运行 `claude --version`:该命令打印您传递的确切版本,例如 `2.1.89 (Claude Code)`。
404 362
405<h3 id="install-with-linux-package-managers">363### 使用 Linux 包管理器安装
406 使用 Linux 包管理器安装
407</h3>
408 364
409Claude Code 发布已签名的 apt、dnf 和 apk 存储库。每个存储库提供两个渠道:`stable` 提供通常约一周前的版本,跳过有重大回归的发布,`latest` 在每个发布发布时立即提供。以下命令配置 `stable` 渠道,适合大多数用户;每个选项卡还显示 `latest` 存储库 URL。包管理器安装不会通过 Claude Code 自动更新;更新通过您的正常系统升级工作流程进行。365Claude Code 发布已签名的 apt、dnf 和 apk 存储库。每个存储库提供两个渠道:`stable` 提供通常约一周前的版本,跳过有重大回归的发布,`latest` 在每个发布发布时立即提供。以下命令配置 `stable` 渠道,适合大多数用户;每个选项卡还显示 `latest` 存储库 URL。包管理器安装不会通过 Claude Code 自动更新;更新通过您的正常系统升级工作流程进行。
410 366
411所有存储库都使用 [Claude Code 发布签名密钥](#binary-integrity-and-code-signing)进行签名。在信任密钥之前,请按照每个选项卡中的说明验证它。367所有存储库都使用 [Claude Code 发布签名密钥](#binary-integrity-and-code-signing)进行签名。在信任密钥之前,请按照每个选项卡中的说明验证它。
412 368
413<Tabs>369**apt**
414 <Tab title="apt">
415 适用于 Debian 和 Ubuntu。以下安装命令使用 `curl` 下载签名密钥,并使用 `gpg` 验证它,新安装的 Debian 和 Ubuntu 可能不包含这两个命令。如果任一命令报告 `command not found`,请先安装两者:
416 370
417 ```bash theme={null}371适用于 Debian 和 Ubuntu。以下安装命令使用 `curl` 下载签名密钥,并使用 `gpg` 验证它,新安装的 Debian 和 Ubuntu 可能不包含这两个命令。如果任一命令报告 `command not found`,请先安装两者:
418 sudo apt install curl gnupg
419 ```
420 372
421 下载签名密钥:373```bash theme={null}
374sudo apt install curl gnupg
375```
422 376
423 ```bash theme={null}377下载签名密钥:
424 sudo install -d -m 0755 /etc/apt/keyrings378
425 sudo curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \379```bash theme={null}
380sudo install -d -m 0755 /etc/apt/keyrings
381sudo curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \
426 -o /etc/apt/keyrings/claude-code.asc382 -o /etc/apt/keyrings/claude-code.asc
427 ```383```
428 384
429 如果此下载失败,`apt update` 稍后会失败并显示 `NO_PUBKEY BAA929FF1A7ECACE`。在继续之前,确认密钥已下载并属于 Anthropic:385如果此下载失败,`apt update` 稍后会失败并显示 `NO_PUBKEY BAA929FF1A7ECACE`。在继续之前,确认密钥已下载并属于 Anthropic:
430 386
431 ```bash theme={null}387```bash theme={null}
432 gpg --show-keys /etc/apt/keyrings/claude-code.asc388gpg --show-keys /etc/apt/keyrings/claude-code.asc
433 ```389```
434 390
435 gpg 打印的指纹应该是 `31DDDE24DDFAB679F42D7BD2BAA929FF1A7ECACE`。如果 gpg 报告文件无法打开或不包含有效的 OpenPGP 数据,则下载失败或返回了错误的内容:确认您的网络可以到达 `downloads.claude.ai`,然后重新运行下载命令。391gpg 打印的指纹应该是 `31DDDE24DDFAB679F42D7BD2BAA929FF1A7ECACE`。如果 gpg 报告文件无法打开或不包含有效的 OpenPGP 数据,则下载失败或返回了错误的内容:确认您的网络可以到达 `downloads.claude.ai`,然后重新运行下载命令。
436 392
437 在 `stable` 渠道上注册存储库并安装:393在 `stable` 渠道上注册存储库并安装:
438 394
439 ```bash theme={null}395```bash theme={null}
440 echo "deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/stable stable main" \396echo "deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/stable stable main" \
441 | sudo tee /etc/apt/sources.list.d/claude-code.list397 | sudo tee /etc/apt/sources.list.d/claude-code.list
442 sudo apt update398sudo apt update
443 sudo apt install claude-code399sudo apt install claude-code
444 ```400```
445 401
446 要改用 `latest` 渠道,URL 路径和套件名称都会改变。使用此 `deb` 行:402要改用 `latest` 渠道,URL 路径和套件名称都会改变。使用此 `deb` 行:
447 403
448 ```bash theme={null}404```bash theme={null}
449 echo "deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/latest latest main" \405echo "deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/latest latest main" \
450 | sudo tee /etc/apt/sources.list.d/claude-code.list406 | sudo tee /etc/apt/sources.list.d/claude-code.list
451 ```407```
452 408
453 要稍后升级,请运行 `sudo apt update && sudo apt upgrade claude-code`。409要稍后升级,请运行 `sudo apt update && sudo apt upgrade claude-code`。
454 </Tab>
455
456 <Tab title="dnf">
457 适用于 Fedora 和 RHEL。以下命令配置 `stable` 渠道:
458
459 ```bash theme={null}
460 sudo tee /etc/yum.repos.d/claude-code.repo <<'EOF'
461 [claude-code]
462 name=Claude Code
463 baseurl=https://downloads.claude.ai/claude-code/rpm/stable
464 enabled=1
465 gpgcheck=1
466 gpgkey=https://downloads.claude.ai/keys/claude-code.asc
467 EOF
468 sudo dnf install claude-code
469 ```
470 410
471 要改用 `latest` 渠道,将 `baseurl` 设置为 `latest` 存储库:411**dnf**
472 412
473 ```ini theme={null}413适用于 Fedora 和 RHEL。以下命令配置 `stable` 渠道:
474 baseurl=https://downloads.claude.ai/claude-code/rpm/latest
475 ```
476 414
477 dnf 在首次安装时下载密钥并提示您确认指纹。在接受之前验证它与 `31DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE` 匹配。415```bash theme={null}
416sudo tee /etc/yum.repos.d/claude-code.repo <<'EOF'
417[claude-code]
418name=Claude Code
419baseurl=https://downloads.claude.ai/claude-code/rpm/stable
420enabled=1
421gpgcheck=1
422gpgkey=https://downloads.claude.ai/keys/claude-code.asc
423EOF
424sudo dnf install claude-code
425```
478 426
479 要稍后升级,请运行 `sudo dnf upgrade claude-code`。427要改用 `latest` 渠道,将 `baseurl` 设置为 `latest` 存储库:
480 </Tab>428
429```ini theme={null}
430baseurl=https://downloads.claude.ai/claude-code/rpm/latest
431```
481 432
482 <Tab title="apk">433dnf 在首次安装时下载密钥并提示您确认指纹。在接受之前验证它与 `31DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE` 匹配。
483 适用于 Alpine Linux。以下命令配置 `stable` 渠道:
484 434
485 ```sh theme={null}435要稍后升级,请运行 `sudo dnf upgrade claude-code`。
486 wget -O /etc/apk/keys/claude-code.rsa.pub \436
437**apk**
438
439适用于 Alpine Linux。以下命令配置 `stable` 渠道:
440
441```sh theme={null}
442wget -O /etc/apk/keys/claude-code.rsa.pub \
487 https://downloads.claude.ai/keys/claude-code.rsa.pub443 https://downloads.claude.ai/keys/claude-code.rsa.pub
488 echo "https://downloads.claude.ai/claude-code/apk/stable" >> /etc/apk/repositories444echo "https://downloads.claude.ai/claude-code/apk/stable" >> /etc/apk/repositories
489 apk add claude-code445apk add claude-code
490 ```446```
491 447
492 要切换到 `latest` 渠道,删除 `stable` 存储库行并添加 `latest` 存储库:448要切换到 `latest` 渠道,删除 `stable` 存储库行并添加 `latest` 存储库:
493 449
494 ```sh theme={null}450```sh theme={null}
495 sed -i '\|downloads.claude.ai/claude-code/apk/stable|d' /etc/apk/repositories451sed -i '\|downloads.claude.ai/claude-code/apk/stable|d' /etc/apk/repositories
496 echo "https://downloads.claude.ai/claude-code/apk/latest" >> /etc/apk/repositories452echo "https://downloads.claude.ai/claude-code/apk/latest" >> /etc/apk/repositories
497 ```453```
498 454
499 使用 `sha256sum /etc/apk/keys/claude-code.rsa.pub` 验证下载的密钥,应该报告 `395759c1f7449ef4cdef305a42e820f3c766d6090d142634ebdb049f113168b6`。455使用 `sha256sum /etc/apk/keys/claude-code.rsa.pub` 验证下载的密钥,应该报告 `395759c1f7449ef4cdef305a42e820f3c766d6090d142634ebdb049f113168b6`。
500 456
501 要稍后升级,请运行 `apk update && apk upgrade claude-code`。457要稍后升级,请运行 `apk update && apk upgrade claude-code`。
502 </Tab>
503</Tabs>
504 458
505<h3 id="install-with-npm">459### 使用 npm 安装
506 使用 npm 安装
507</h3>
508 460
509您也可以将 Claude Code 安装为全局 npm 包。npm 包需要 [Node.js 22 或更高版本](https://nodejs.org/en/download)。在较旧的 Node.js 版本上,npm 在安装期间打印 `EBADENGINE` 警告而不是失败;安装完成,`claude` 仍然运行,因为该包下载了在运行时不使用您的 Node.js 的原生二进制文件。461您也可以将 Claude Code 安装为全局 npm 包。npm 包需要 [Node.js 22 或更高版本](https://nodejs.org/en/download)。在较旧的 Node.js 版本上,npm 在安装期间打印 `EBADENGINE` 警告而不是失败;安装完成,`claude` 仍然运行,因为该包下载了在运行时不使用您的 Node.js 的原生二进制文件。
510 462
518 470
519要升级 npm 安装,请运行 `npm install -g @anthropic-ai/claude-code@latest`。避免使用 `npm update -g`,因为它遵循原始安装的 semver 范围,可能不会将您移动到最新版本。471要升级 npm 安装,请运行 `npm install -g @anthropic-ai/claude-code@latest`。避免使用 `npm update -g`,因为它遵循原始安装的 semver 范围,可能不会将您移动到最新版本。
520 472
521<Warning>473> [!WARNING]
522 不要使用 `sudo npm install -g`,因为这可能导致权限问题和安全风险。如果遇到权限错误,请参阅[故障排除权限错误](/docs/zh-CN/troubleshoot-install#permission-errors-during-installation)。474>
523</Warning>475> 不要使用 `sudo npm install -g`,因为这可能导致权限问题和安全风险。如果遇到权限错误,请参阅[故障排除权限错误](/docs/zh-CN/troubleshoot-install#permission-errors-during-installation)。
524 476
525<h3 id="install-on-network-storage">477### 在网络存储上安装
526 在网络存储上安装
527</h3>
528 478
529正在运行的会话在工作过程中会从磁盘读取 Claude Code 可执行文件的部分内容,而不仅仅是在启动时读取。如果该文件在会话中途变得不可读,例如因为它在网络存储上被截断或删除,会话就会崩溃。在 Linux 上,您的 shell 会将此报告为 `Bus error`。479正在运行的会话在工作过程中会从磁盘读取 Claude Code 可执行文件的部分内容,而不仅仅是在启动时读取。如果该文件在会话中途变得不可读,例如因为它在网络存储上被截断或删除,会话就会崩溃。在 Linux 上,您的 shell 会将此报告为 `Bus error`。
530 480
537 487
538原生安装程序会自行从 `~/.local/share/claude/versions/` 中删除旧版本,当该目录位于共享存储上时,这一点尤为重要。除了启动器指向的版本以及同一台机器上的会话正在运行的任何版本之外,它会保留最新的两个版本并删除其余版本。另一台机器上正在运行已删除版本的会话将失去其二进制文件。使用[自定义启动器](#auto-updates)时,Claude Code 会保留所有已安装的版本,并由您自行负责清理。488原生安装程序会自行从 `~/.local/share/claude/versions/` 中删除旧版本,当该目录位于共享存储上时,这一点尤为重要。除了启动器指向的版本以及同一台机器上的会话正在运行的任何版本之外,它会保留最新的两个版本并删除其余版本。另一台机器上正在运行已删除版本的会话将失去其二进制文件。使用[自定义启动器](#auto-updates)时,Claude Code 会保留所有已安装的版本,并由您自行负责清理。
539 489
540<h3 id="binary-integrity-and-code-signing">490### 二进制完整性和代码签名
541 二进制完整性和代码签名
542</h3>
543 491
544每个发布都发布一个 `manifest.json`,其中包含每个平台二进制文件的 SHA256 校验和。清单使用 Anthropic GPG 密钥签名,因此验证清单上的签名可以传递地验证它列出的每个二进制文件。492每个发布都发布一个 `manifest.json`,其中包含每个平台二进制文件的 SHA256 校验和。清单使用 Anthropic GPG 密钥签名,因此验证清单上的签名可以传递地验证它列出的每个二进制文件。
545 493
546<h4 id="verify-the-manifest-signature">494#### 验证清单签名
547 验证清单签名
548</h4>
549 495
550步骤 1-3 需要带有 `gpg` 和 `curl` 的 POSIX shell。在 Windows 上,在 Git Bash 或 WSL 中运行它们。步骤 4 包括 PowerShell 选项。496步骤 1-3 需要带有 `gpg` 和 `curl` 的 POSIX shell。在 Windows 上,在 Git Bash 或 WSL 中运行它们。步骤 4 包括 PowerShell 选项。
551 497
552<Steps>498**1. 下载并导入公钥**
553 <Step title="下载并导入公钥">
554 发布签名密钥发布在固定 URL。
555 499
556 ```bash theme={null}500发布签名密钥发布在固定 URL。
557 curl -fsSL https://downloads.claude.ai/keys/claude-code.asc | gpg --import
558 ```
559 501
560 显示导入的密钥的指纹。502```bash theme={null}
503curl -fsSL https://downloads.claude.ai/keys/claude-code.asc | gpg --import
504```
561 505
562 ```bash theme={null}506显示导入的密钥的指纹。
563 gpg --fingerprint security@anthropic.com
564 ```
565 507
566 确认输出包含此指纹:508```bash theme={null}
509gpg --fingerprint security@anthropic.com
510```
567 511
568 ```text theme={null}512确认输出包含此指纹:
569 31DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE
570 ```
571 </Step>
572 513
573 <Step title="下载清单和签名">514```text theme={null}
574 将 `VERSION` 设置为您要验证的发布。51531DD DE24 DDFA B679 F42D 7BD2 BAA9 29FF 1A7E CACE
516```
575 517
576 ```bash theme={null}518**2. 下载清单和签名**
577 REPO=https://downloads.claude.ai/claude-code-releases
578 VERSION=2.1.89
579 curl -fsSLO "$REPO/$VERSION/manifest.json"
580 curl -fsSLO "$REPO/$VERSION/manifest.json.sig"
581 ```
582 </Step>
583 519
584 <Step title="验证签名">520将 `VERSION` 设置为您要验证的发布。
585 针对清单验证分离的签名。
586 521
587 ```bash theme={null}522```bash theme={null}
588 gpg --verify manifest.json.sig manifest.json523REPO=https://downloads.claude.ai/claude-code-releases
589 ```524VERSION=2.1.89
525curl -fsSLO "$REPO/$VERSION/manifest.json"
526curl -fsSLO "$REPO/$VERSION/manifest.json.sig"
527```
590 528
591 有效的结果报告 `Good signature from "Anthropic Claude Code Release Signing <security@anthropic.com>"`。529**3. 验证签名**
592 530
593 `gpg` 也会为任何新导入的密钥打印 `WARNING: This key is not certified with a trusted signature!`。这是预期的。`Good signature` 行确认密码学检查通过。第 1 步中的指纹比较确认密钥本身是真实的。531针对清单验证分离的签名。
594 </Step>
595 532
596 <Step title="根据清单检查二进制文件">533```bash theme={null}
597 将二进制文件的 SHA256 校验和与 `manifest.json` 中 `platforms.<platform>.checksum` 下列出的值进行比较。以下命令假设当前目录中有 `claude` 二进制文件。要验证已安装的原生二进制文件,请针对 `~/.local/share/claude/versions/VERSION` 运行命令,将 VERSION 替换为您在第 2 步中设置的发布。534gpg --verify manifest.json.sig manifest.json
535```
598 536
599 <Tabs>537有效的结果报告 `Good signature from "Anthropic Claude Code Release Signing <security@anthropic.com>"`。
600 <Tab title="Linux">
601 ```bash theme={null}
602 sha256sum claude
603 ```
604 </Tab>
605 538
606 <Tab title="macOS">539`gpg` 也会为任何新导入的密钥打印 `WARNING: This key is not certified with a trusted signature!`。这是预期的。`Good signature` 行确认密码学检查通过。第 1 步中的指纹比较确认密钥本身是真实的。
607 ```bash theme={null}
608 shasum -a 256 claude
609 ```
610 </Tab>
611 540
612 <Tab title="Windows PowerShell">541**4. 根据清单检查二进制文件**
613 ```powershell theme={null}542
614 (Get-FileHash claude.exe -Algorithm SHA256).Hash.ToLower()543将二进制文件的 SHA256 校验和与 `manifest.json` 中 `platforms.<platform>.checksum` 下列出的值进行比较。以下命令假设当前目录中有 `claude` 二进制文件。要验证已安装的原生二进制文件,请针对 `~/.local/share/claude/versions/VERSION` 运行命令,将 VERSION 替换为您在第 2 步中设置的发布。
615 ```544
616 </Tab>545**Linux**
617 </Tabs>546
618 </Step>547```bash theme={null}
619</Steps>548sha256sum claude
549```
550
551**macOS**
620 552
621<Note>553```bash theme={null}
622 清单签名可用于 `2.1.89` 及以后的发布。较早的发布在 `manifest.json` 中发布校验和,但没有分离的签名。554shasum -a 256 claude
623</Note>555```
556
557**Windows PowerShell**
624 558
625<h4 id="platform-code-signatures">559```powershell theme={null}
626 平台代码签名560(Get-FileHash claude.exe -Algorithm SHA256).Hash.ToLower()
627</h4>561```
562
563> [!NOTE]
564>
565> 清单签名可用于 `2.1.89` 及以后的发布。较早的发布在 `manifest.json` 中发布校验和,但没有分离的签名。
566
567#### 平台代码签名
628 568
629除了签名的清单外,各个二进制文件在支持的地方还带有平台原生代码签名。569除了签名的清单外,各个二进制文件在支持的地方还带有平台原生代码签名。
630 570
632* **Windows**:由"Anthropic, PBC"签名。使用 `Get-AuthenticodeSignature .\claude.exe` 验证。572* **Windows**:由"Anthropic, PBC"签名。使用 `Get-AuthenticodeSignature .\claude.exe` 验证。
633* **Linux**:二进制文件不单独进行代码签名。如果您直接从 `claude-code-releases` 存储桶下载或使用原生安装程序,请使用上面的清单签名验证完整性。如果您使用 [apt、dnf 或 apk](#install-with-linux-package-managers) 安装,您的包管理器会使用存储库签名密钥自动验证签名。573* **Linux**:二进制文件不单独进行代码签名。如果您直接从 `claude-code-releases` 存储桶下载或使用原生安装程序,请使用上面的清单签名验证完整性。如果您使用 [apt、dnf 或 apk](#install-with-linux-package-managers) 安装,您的包管理器会使用存储库签名密钥自动验证签名。
634 574
635<h2 id="uninstall-claude-code">575## 卸载 Claude Code
636 卸载 Claude Code
637</h2>
638 576
639要删除 Claude Code,请按照您的安装方法的说明进行操作。如果之后 `claude` 仍然运行,您可能有第二个安装或来自较旧安装程序的遗留 shell 别名。请参阅[检查冲突的安装](/docs/zh-CN/troubleshoot-install#check-for-conflicting-installations)以查找并删除它。577要删除 Claude Code,请按照您的安装方法的说明进行操作。如果之后 `claude` 仍然运行,您可能有第二个安装或来自较旧安装程序的遗留 shell 别名。请参阅[检查冲突的安装](/docs/zh-CN/troubleshoot-install#check-for-conflicting-installations)以查找并删除它。
640 578
641<span id="native-installation" />579### 卸载原生安装
642
643<h3 id="uninstall-a-native-installation">
644 卸载原生安装
645</h3>
646 580
647删除 Claude Code 二进制文件和版本文件:581删除 Claude Code 二进制文件和版本文件:
648 582
649<Tabs>583**macOS、Linux、WSL**
650 <Tab title="macOS、Linux、WSL">
651 ```bash theme={null}
652 rm -f ~/.local/bin/claude
653 rm -rf ~/.local/share/claude
654 ```
655 </Tab>
656 584
657 <Tab title="Windows PowerShell">585```bash theme={null}
658 ```powershell theme={null}586rm -f ~/.local/bin/claude
659 Remove-Item -Path "$env:USERPROFILE\.local\bin\claude.exe" -Force587rm -rf ~/.local/share/claude
660 Remove-Item -Path "$env:USERPROFILE\.local\share\claude" -Recurse -Force588```
661 ```
662 </Tab>
663</Tabs>
664 589
665<span id="homebrew-installation" />590**Windows PowerShell**
666 591
667<h3 id="uninstall-with-homebrew">592```powershell theme={null}
668 使用 Homebrew 卸载593Remove-Item -Path "$env:USERPROFILE\.local\bin\claude.exe" -Force
669</h3>594Remove-Item -Path "$env:USERPROFILE\.local\share\claude" -Recurse -Force
595```
596
597### 使用 Homebrew 卸载
670 598
671删除您安装的 Homebrew cask。如果您安装了稳定版 cask:599删除您安装的 Homebrew cask。如果您安装了稳定版 cask:
672 600
680brew uninstall --cask claude-code@latest608brew uninstall --cask claude-code@latest
681```609```
682 610
683<span id="winget-installation" />611### 使用 WinGet 卸载
684
685<h3 id="uninstall-with-winget">
686 使用 WinGet 卸载
687</h3>
688 612
689删除 WinGet 包:613删除 WinGet 包:
690 614
692winget uninstall Anthropic.ClaudeCode616winget uninstall Anthropic.ClaudeCode
693```617```
694 618
695<span id="apt-/-dnf-/-apk" />619### 使用 apt、dnf 或 apk 卸载
696
697<h3 id="uninstall-with-apt-dnf-or-apk">
698 使用 apt、dnf 或 apk 卸载
699</h3>
700 620
701删除包和存储库配置:621删除包和存储库配置:
702 622
703<Tabs>623**apt**
704 <Tab title="apt">
705 ```bash theme={null}
706 sudo apt remove claude-code
707 sudo rm /etc/apt/sources.list.d/claude-code.list /etc/apt/keyrings/claude-code.asc
708 ```
709 </Tab>
710 624
711 <Tab title="dnf">625```bash theme={null}
712 ```bash theme={null}626sudo apt remove claude-code
713 sudo dnf remove claude-code627sudo rm /etc/apt/sources.list.d/claude-code.list /etc/apt/keyrings/claude-code.asc
714 sudo rm /etc/yum.repos.d/claude-code.repo628```
715 ```
716 </Tab>
717 629
718 <Tab title="apk">630**dnf**
719 ```sh theme={null}
720 apk del claude-code
721 sed -i '\|downloads.claude.ai/claude-code/apk|d' /etc/apk/repositories
722 rm /etc/apk/keys/claude-code.rsa.pub
723 ```
724 </Tab>
725</Tabs>
726 631
727<span id="npm" />632```bash theme={null}
633sudo dnf remove claude-code
634sudo rm /etc/yum.repos.d/claude-code.repo
635```
636
637**apk**
638
639```sh theme={null}
640apk del claude-code
641sed -i '\|downloads.claude.ai/claude-code/apk|d' /etc/apk/repositories
642rm /etc/apk/keys/claude-code.rsa.pub
643```
728 644
729<h3 id="uninstall-with-npm">645### 使用 npm 卸载
730 使用 npm 卸载
731</h3>
732 646
733删除全局 npm 包:647删除全局 npm 包:
734 648
736npm uninstall -g @anthropic-ai/claude-code650npm uninstall -g @anthropic-ai/claude-code
737```651```
738 652
739<h3 id="remove-configuration-files">653### 删除配置文件
740 删除配置文件
741</h3>
742 654
743<Warning>655> [!WARNING]
744 删除配置文件将删除您的所有设置、允许的工具、MCP 服务器配置和会话历史记录。656>
745</Warning>657> 删除配置文件将删除您的所有设置、允许的工具、MCP 服务器配置和会话历史记录。
746 658
747VS Code 扩展、JetBrains 插件和桌面应用也会写入 `~/.claude/`。如果其中任何一个仍然安装,下次运行时目录会被重新创建。要完全删除 Claude Code,请在删除这些文件之前卸载 [VS Code 扩展](/docs/zh-CN/vs-code#uninstall-the-extension)、JetBrains 插件和桌面应用。659VS Code 扩展、JetBrains 插件和桌面应用也会写入 `~/.claude/`。如果其中任何一个仍然安装,下次运行时目录会被重新创建。要完全删除 Claude Code,请在删除这些文件之前卸载 [VS Code 扩展](/docs/zh-CN/vs-code#uninstall-the-extension)、JetBrains 插件和桌面应用。
748 660
749要删除 Claude Code 设置和缓存数据:661要删除 Claude Code 设置和缓存数据:
750 662
751<Tabs>663**macOS、Linux、WSL**
752 <Tab title="macOS、Linux、WSL">
753 ```bash theme={null}
754 # 删除用户设置和状态
755 rm -rf ~/.claude
756 rm ~/.claude.json
757 664
758 # 删除特定于项目的设置(从您的项目目录运行)665```bash theme={null}
759 rm -rf .claude666# 删除用户设置和状态
760 rm -f .mcp.json667rm -rf ~/.claude
761 ```668rm ~/.claude.json
762 </Tab>
763 669
764 <Tab title="Windows PowerShell">670# 删除特定于项目的设置(从您的项目目录运行)
765 ```powershell theme={null}671rm -rf .claude
766 # 删除用户设置和状态672rm -f .mcp.json
767 Remove-Item -Path "$env:USERPROFILE\.claude" -Recurse -Force673```
768 Remove-Item -Path "$env:USERPROFILE\.claude.json" -Force
769 674
770 # 删除特定于项目的设置(从您的项目目录运行)675**Windows PowerShell**
771 Remove-Item -Path ".claude" -Recurse -Force676
772 Remove-Item -Path ".mcp.json" -Force677```powershell theme={null}
773 ```678# 删除用户设置和状态
774 </Tab>679Remove-Item -Path "$env:USERPROFILE\.claude" -Recurse -Force
775</Tabs>680Remove-Item -Path "$env:USERPROFILE\.claude.json" -Force
681
682# 删除特定于项目的设置(从您的项目目录运行)
683Remove-Item -Path ".claude" -Recurse -Force
684Remove-Item -Path ".mcp.json" -Force
685```