← 返回命令列表

Linux command

cargo-geiger 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Scan

cargo geiger

Output

cargo geiger --output-format json

Include only build dependencies

cargo geiger --build-dependencies

Scan

cargo geiger --no-default-features

说明

cargo-geiger is a Cargo subcommand that scans a Rust project's dependency tree to detect and report usage of unsafe Rust code. It counts unsafe expressions, function declarations, trait implementations, and method calls in both the project and all its dependencies. The output shows a tree view of the dependency graph annotated with counts of unsafe code usage, helping developers assess the safety profile of their dependency chain. Crates using `#!forbid(unsafe_code)` are clearly marked as verified safe. The name is a reference to a Geiger counter, which detects radiation — similarly, cargo-geiger detects potentially dangerous unsafe code.

参数

--all-dependencies
Include all dependencies in the scan.
--build-dependencies
Include build dependencies.
--dev-dependencies
Include development dependencies.
--output-format _FORMAT_
Output format: ascii-tree (default) or json.
--no-default-features
Do not activate the default feature.
--features _FEATURES_
Space or comma separated list of features to activate.
--update-readme
Update a safety report in the project README.
--forbid-only
Only report crates that don't use `#!forbid(unsafe_code)`.

FAQ

What is the cargo-geiger command used for?

cargo-geiger is a Cargo subcommand that scans a Rust project's dependency tree to detect and report usage of unsafe Rust code. It counts unsafe expressions, function declarations, trait implementations, and method calls in both the project and all its dependencies. The output shows a tree view of the dependency graph annotated with counts of unsafe code usage, helping developers assess the safety profile of their dependency chain. Crates using `#!forbid(unsafe_code)` are clearly marked as verified safe. The name is a reference to a Geiger counter, which detects radiation — similarly, cargo-geiger detects potentially dangerous unsafe code.

How do I run a basic cargo-geiger example?

Run `cargo geiger` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --all-dependencies do in cargo-geiger?

Include all dependencies in the scan.