cargo metadata --format-version 1Useful when diagnosing workspace membership, package names, targets, and dependency resolution.
Commands and examples for debugging Cargo.toml issues, package selection mistakes, and workspace confusion in Rust CLI repos.
Inspect package metadata and validate how Cargo sees the workspace.
cargo metadata --format-version 1Useful when diagnosing workspace membership, package names, targets, and dependency resolution.
cargo locate-projectHelpful when commands are being run from nested directories and the active manifest is unclear.
cargo locate-project --workspaceUseful when troubleshooting commands that behave differently in a workspace root versus a package directory.
cargo build -p my-cliAvoids accidentally building the wrong package or the whole workspace when only one member matters.
cargo run -p my-cli --bin my-cliUseful when multiple binaries or packages share similar names.
Remove build artifacts for a package or target selection context.
cargo clean -p my-cliSometimes stale artifacts or profile mismatches make a local clean rebuild useful.
Examples for frequent Cargo.toml issues in CLI projects.
[workspace]
members = ["crates/my-cli", "crates/common"]
resolver = "2"When a package is missing from workspace commands, verify that it is listed under `members` or matched by a glob you intended.
[[bin]]
name = "my-cli"
path = "src/main.rs"Useful if Cargo cannot find the binary target you expect or if the project contains multiple executables.
[dependencies]
clap = { version = "4", features = ["derive"] }
serde_json = { version = "1", optional = true }
[features]
default = []
json = ["dep:serde_json"]Feature wiring mistakes in `Cargo.toml` are a common source of build confusion in CLI apps.