Linux command
rustup-init.sh 命令
网络
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Install without prompts
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
Install nightly toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly
Install minimal profile without modifying PATH
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --no-modify-path
Install with additional target for cross-compilation
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --target wasm32-unknown-unknown
Install with additional components
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --component rustfmt clippy
说明
rustup-init.sh is the Rust toolchain installer script. Downloads and runs rustup-init to install rustup and the Rust toolchain. This is the official method for installing Rust on Unix systems. Options can also be set via environment variables prefixed with RUSTUP_INIT_ (e.g., RUSTUP_INIT_DEFAULT_TOOLCHAIN=nightly).
参数
- -y
- Accept defaults without prompting.
- -q, --quiet
- Disable progress output.
- -v, --verbose
- Enable verbose output.
- --default-toolchain _name_
- Install specific toolchain (stable, beta, nightly, or a version like 1.78.0).
- --default-host _triple_
- Set the default host triple (e.g., x86_64-unknown-linux-gnu).
- --no-modify-path
- Don't modify the PATH environment variable.
- --profile _name_
- Installation profile: minimal (rustc, cargo), default (adds rustfmt, clippy), or complete (all components).
- --component _name_
- Add a specific component (e.g., rust-docs, rustfmt, clippy). Can be specified multiple times.
- --target _triple_
- Add a cross-compilation target (e.g., wasm32-unknown-unknown). Can be specified multiple times.
FAQ
What is the rustup-init.sh command used for?
rustup-init.sh is the Rust toolchain installer script. Downloads and runs rustup-init to install rustup and the Rust toolchain. This is the official method for installing Rust on Unix systems. Options can also be set via environment variables prefixed with RUSTUP_INIT_ (e.g., RUSTUP_INIT_DEFAULT_TOOLCHAIN=nightly).
How do I run a basic rustup-init.sh example?
Run `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -y do in rustup-init.sh?
Accept defaults without prompting.