Linux command
cargo-install 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Install from crates.io
cargo install [ripgrep]
Install specific version
cargo install [tokei@12.1.0]
Install from git repository
cargo install --git [https://github.com/user/repo]
Install from local path
cargo install --path [.]
Force reinstall
cargo install --force [package]
List installed packages
cargo install --list
Install to custom location
cargo install --root [~/.local] [package]
说明
cargo install builds and installs Rust binary crates from crates.io, git repositories, or local paths. Binaries are installed to ~/.cargo/bin/ by default. Only packages with [bin] or [example] targets can be installed.
参数
- --version _version_
- Version requirement (e.g., ~1.2, ^1.0)
- --git _url_
- Install from git repository
- --branch _branch_
- Git branch
- --tag _tag_
- Git tag
- --rev _sha_
- Git commit
- --path _path_
- Install from local path
- --root _dir_
- Installation directory
- -f, --force
- Overwrite existing binaries
- --list
- List installed packages
- --bins
- Install all binaries
- --examples
- Install all examples
- --no-track
- Don't save tracking information
- --locked
- Use Cargo.lock versions
- -j, --jobs _n_
- Parallel build jobs
- --features _features_
- Enable specified features
- --all-features
- Enable all features
- --no-default-features
- Disable the package's default feature set.
- --target _TRIPLE_
- Cross-compile binaries for the specified target triple.
- --profile _NAME_
- Build with the named profile (e.g., _release_, _dev_).
- --debug
- Build with the dev profile (faster compile, slower binary).
FAQ
What is the cargo-install command used for?
cargo install builds and installs Rust binary crates from crates.io, git repositories, or local paths. Binaries are installed to ~/.cargo/bin/ by default. Only packages with [bin] or [example] targets can be installed.
How do I run a basic cargo-install example?
Run `cargo install [ripgrep]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --version _version_ do in cargo-install?
Version requirement (e.g., ~1.2, ^1.0)