# 安装 Aptos CLI

Aptos 工具是一个命令行界面（CLI），用来在 Aptos 区块链上进行开发，进行智能合约 debug，以及节点运营。此份文档描述了如何安装 Aptos CLI。查看[使用 Aptos CLI](/aptos-kai-fa-zhe-wen-dang/aptos-cli/shi-yong-aptos-cli.md)。

在你的平台上，下载预编译二进制文件来安装 CLI，如下文所述：

{% hint style="info" %}
💡 **MOVE prover 依赖项**&#x20;

如果你想使用 Move prover，在安装 CLI libary 之后，安装[MOVE prover依赖](#ke-xuan-an-zhuang-move-prover-yi-lai)项
{% endhint %}

## 下载预编译二进制文件

1. 进入 [Aptos CLI 发布页面](https://github.com/aptos-labs/aptos-core/releases?q=cli\&expanded=true)
2. 在最新发布的部分中，你可以看到有这样格式文件名的压缩文档：`aptos-cli-<version>-<platform>`。这些是基于平台的预编译二进制文件。下载他们。
3. 解压缩这些文件，将把 aptos CLI 二进制文件压缩至你的默认下载文件夹。例如，在 MacOS 中是 `~/Downloads` 文件夹
4. 将这个解压后的文件放到你常用的本地文件夹中。例如，在 Linux 或者 MacOS 中，放在`~/bin/aptos` 文件夹中

   💡 **升级？记得查看默认下载文件夹：** 当你更新 CLI 二进制文件到最新版本，新的版本会下载至默认文件夹。记得把它移动到`~/bin/aptos`，覆盖旧版本
5. 运行下面的命令来执行 `~/bin/aptos`：
   * Linux 和 MacOS：`chmod +x ~/bin/aptos`
   * 在 MacOS 上，当你第一次尝试运行 aptos 工具，将会被提示“来自未知开发者”，这属于正常情况，依照 Apple 支持中心的简单几个步骤，来解除这个阻止：[从未知开发者处打开 Mac 应用程序](https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac)
6. 输入 `~/bin/aptos help` 来阅读帮助指南
7. 在`.bashrc`或者 `.zshrc`文件中增加 `~/bin` 路径，以备未来用到

## （可选）安装 Move Prover 依赖

依照下列步骤安装 Move Prover：

{% hint style="info" %}
💡 **Windows 系统不支持 Move Prover**
{% endhint %}

1. 确保你已经安装了git：<https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>
2. 克隆 Aptos 核心仓库：`git clone <https://github.com/aptos-labs/aptos-core.git`>
3. 把路径改为 aptos-core 路径：`cd aptos-core`
4. 执行开发设置脚本来准备环境：`./scripts/dev_setup.sh -yp`
5. 对配置文件执行 source 指令： `source ~/.profile`

   \<aside> 💡 **信息** 注意你需要在 `~/.profile` 中包含环境变量定义，根据你的设置，`~/.profile` 可能已经自动地加载到每个登录 shell，也可能没有，你需要在 `~/.bash_profile` 中增加 `. ~/.profile`，或者在其他 shell 的配置中手动增加。

   \</aside>
6. 执行 Move Prover 来验证一个示例：

   ```
   aptos move prove --package-dir aptos-move/move-examples/hello_prover/
   ```

* （仅限高级用户）从源代码构建 CLI 二进制文件

  如果您是高级用户并且想通过下载源代码来构建 CLI 二进制文件，请按照以下步骤操作。 **不建议这样做。**

  1. 确保您已安装 git[https://git-scm.com/book/en/v2/Getting-Started-Installing-Git。](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git%E3%80%82)
  2. 克隆 Aptos 核心仓库：`git clone [<https://github.com/aptos-labs/aptos-core.git`。>]\([https://github.com/aptos-labs/aptos-core.git](https://github.com/aptos-labs/aptos-core.git%E3%80%82))。
  3. 将目录更改为 `aptos-core` 目录：`cd aptos-core`。
  4. 运行开发设置脚本以准备您的环境：`./scripts/dev_setup.sh`。
  5. 更新你当前的 shell 环境：`source ~/.cargo/env`。
  6. 签出正确的分支 `git checkout --track origin/<branch>`，其中 `<branch>` 是：
     * devnet 用于在 Aptos devnet 上构建。
     * testnet 用于在 Aptos 测试网上构建。
     * main 用于当前的开发分支。
  7. 构建 CLI 工具：`cargo build --package aptos --release`。
  8. 二进制文件将在 `target/release/aptos` 文件夹中可用。
  9. （可选）将此可执行文件移动到路径上的某个位置，例如 `~/bin/aptos`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gushi10546.gitbook.io/aptos-kai-fa-zhe-wen-dang/aptos-cli/an-zhuang-aptos-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
