Description
Problem
In certain environments that tightly control dependencies (e.g. for the purposes of supply-chain security) the dev-dependencies are not present when code is compiled. But cargo metadata
always tries to collect data for the entire dependency tree, including dev-dependencies. It errors out and reports no info if dev-dependencies are missing.
In practical terms this blocks the deployment of cargo auditable
(which relies on cargo metadata
) within Debian (which does not package dev-dependencies).
This is similar to #10718, but this isn't just a problem with feature unification - the dev-dependency packages are not present at all.
Proposed Solution
Adding a new flag, --no-dev-deps
(following the precedent of the existing --no-deps
flag) so that cargo metadata
wouldn't attempt to query dev-dependencies would resolve this.
Cargo generating a SBOM natively would also solve this by letting cargo auditable
bypass cargo metadata
completely. But that's going to take a long time to reach stable. That feature isn't even on nightly yet, since the reviews of the RFC and the implementation PR seem to have stalled.
Making it possible to query cargo metadata
without requiring dev-dependencies to be present seems like a simpler and more straightforward change that shouldn't require as much design and stabilization work.
Notes
cargo auditable
got a lot of uptake from Linux distributions. 5 distros, including Alpine and NixOS, are already building all their Rust packages with it. There is also interest from Debian, but this issue makes adopting cargo auditable
a non-starter in their environment.