Skip to content

安装和构建

系统要求

要求详情
操作系统macOS 12+、Ubuntu 20.04+/Debian 10+ 或 Windows 11 通过 WSL2
Git(可选,推荐)2.23+ 用于内置 PR 帮助程序
RAM最少 4GB(推荐 8GB)

DotSlash

GitHub Release 还包含 Codex CLI 的 DotSlash 文件,名为 codex。使用 DotSlash 文件可以轻松地对源代码控制进行轻量级提交,以确保所有贡献者使用相同版本的可执行文件,无论他们用于开发的平台如何。

从源代码构建

bash
# 克隆存储库并导航到 Cargo 工作区的根目录。
git clone https://github.com/openai/codex.git
cd codex/codex-rs

# 如果需要,请安装 Rust 工具链。
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustup component add rustfmt
rustup component add clippy
# 安装工作区 justfile 使用的帮助程序工具:
cargo install just
# 可选:安装 nextest 用于 `just test` 帮助程序(或使用 `cargo test --all-features` 作为备选)
cargo install cargo-nextest

# 构建 Codex。
cargo build

# 使用示例提示启动 TUI。
cargo run --bin codex -- "explain this codebase to me"

# 进行更改后,使用根 justfile 帮助程序(它们默认为 codex-rs):
just fmt
just fix -p <crate-you-touched>

# 运行相关的测试(项目特定的速度最快),例如:
cargo test -p codex-tui
# 如果您安装了 cargo-nextest,`just test` 会运行完整套件:
just test
# 否则,回退到:
cargo test --all-features