Linux command
cargo-remove 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Remove dependency
cargo remove [serde]
Remove dev dependency
cargo remove --dev [mockall]
Remove build dependency
cargo remove --build [cc]
Remove multiple dependencies
cargo remove [serde] [tokio] [regex]
Remove target-specific dependency
cargo remove --target [x86_64-pc-windows-gnu] [winapi]
Dry run
cargo remove --dry-run [package]
说明
cargo remove removes one or more dependencies from the Cargo.toml manifest file. It can target regular dependencies, dev-dependencies, build-dependencies, or platform-specific dependency sections. The command modifies Cargo.toml directly but does not update Cargo.lock until the next build or `cargo update`. Multiple dependencies can be removed in a single invocation. Use `--dry-run` to preview changes before applying them.
参数
- --dev, -D
- Remove from dev-dependencies
- --build, -B
- Remove from build-dependencies
- --target _triple_
- Remove from target-specific dependencies
- -p, --package _spec_
- Package to modify
- --dry-run
- Show changes without modifying manifest
- --manifest-path _path_
- Path to Cargo.toml
- -v, --verbose
- Verbose output
- -q, --quiet
- Suppress output
FAQ
What is the cargo-remove command used for?
cargo remove removes one or more dependencies from the Cargo.toml manifest file. It can target regular dependencies, dev-dependencies, build-dependencies, or platform-specific dependency sections. The command modifies Cargo.toml directly but does not update Cargo.lock until the next build or `cargo update`. Multiple dependencies can be removed in a single invocation. Use `--dry-run` to preview changes before applying them.
How do I run a basic cargo-remove example?
Run `cargo remove [serde]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --dev, -D do in cargo-remove?
Remove from dev-dependencies