| Crates.io | cargo-whys |
| lib.rs | cargo-whys |
| version | 0.1.0 |
| created_at | 2026-01-12 22:35:10.852653+00 |
| updated_at | 2026-01-12 22:35:10.852653+00 |
| description | A cargo subcommand that explains why dependencies are in your tree |
| homepage | |
| repository | https://github.com/polysystems/cargo-why |
| max_upload_size | |
| id | 2038981 |
| size | 45,088 |
A cargo subcommand that explains why dependencies are in your tree.
cargo install cargo-whys
Or build from source:
git clone https://github.com/polysystems/cargo-whys
cd cargo-whys
cargo install --path .
Find out why a dependency is in your tree:
cargo why serde
Output:
Analyzing dependency: serde
Version: 1.0.210
Used by:
• axum 0.7.0 [external]
• config 0.13.0 [external]
• my-app 0.1.0 [workspace]
Total imports found: 32 in codebase
Tip: Run with --where-used to see where it's used
See where in your codebase the dependency is imported:
cargo why serde --where-used
Output:
Analyzing dependency: serde
Version: 1.0.210
Used by:
• axum 0.7.0 [external]
• my-app 0.1.0 [workspace]
Total imports found: 32 in codebase
Usage locations:
• src/main.rs:3
use serde::{Serialize, Deserialize};
• src/models/user.rs:1
use serde::Serialize;
• src/config.rs:2
use serde_json;
If multiple versions of a dependency exist in your tree:
cargo why serde --all-versions
For programmatic use:
cargo why serde --json
Output:
{
"dependency_name": "serde",
"found": true,
"versions": [
{
"version": "1.0.210",
"used_by": [
{
"name": "my-app",
"version": "0.1.0",
"is_workspace_member": true
},
{
"name": "axum",
"version": "0.7.0",
"is_workspace_member": false
}
]
}
],
"total_usage_count": 32,
"usage_locations": null
}
Analyze a project in a different directory:
cargo why serde --manifest-path /path/to/project
cargo why <DEPENDENCY> [OPTIONS]
Arguments:
<DEPENDENCY> The dependency name to analyze
Options:
--where-used Show where in the codebase the dependency is used
--manifest-path <PATH> Path to the Cargo project directory [default: .]
--all-versions Show all versions of the dependency in the tree
--json Output in JSON format
-h, --help Print help
-V, --version Print version
Contributions are welcome! Please feel free to submit a Pull Request.
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)