Cargo needs network access if a library's build script calls cargo metadata
since 1.84
#15272
Labels
A-build-scripts
Area: build.rs scripts
A-offline
Area: offline mode
C-bug
Category: bug
Command-metadata
S-triage
Status: This issue is waiting on initial triage.
Problem
This is another unintentional behavior change with #13447 dd698ff.
Because in 1.84 Cargo also includes
Cargo.lock
for library only crate.If a dependency has a build script that invokes
cargo metadata
, and there is a lockfile at the package root of the dependency, Cargo respects the lockfile and download necessary crate versions it needs.And it causes a problem that the lockfile might have an outdated/unused dependency than our local package never used. For example, our local package may resolves to
anyhow@2.3.4
, but the lockfile stays inanyhow@2.0.1
. Then thecargo metadata
call with the package will have extra downloads of useless crates, as they never shown up in our dependency graph.It is usually not a concern if people have network access, but not when without.
We already have an issue about
-Zavoid-dev-deps
and #14794 thatcargo metadata
are downloading dev-dependencies, which is not necessary if the call is from some tools or a build script of a dependency.This failure mode not only makes me concern the offline usage. If
cargo metadata
from a build script respects the lockfile from it, and resolves to different dependency versions, does that mean the result of callingcargo metadata
from a dependency's build script is inaccurate? Of course if they don't want any dependency information, they should callcargo metadata --no-deps
instead. However, the aya-rustc-llvm-proxy does want to know about dependencies, and might resolve to wrong versions.Surely this is already a problem before #13447, but with #13447 it might affect more people.
Steps
And you'll see
Possible Solution(s)
I don't know if it is considered a bug. Given it is pretty common in a build script
cargo metadata
is called. This will affect more and more people working in a network-contained environment.Notes
No response
Version
The text was updated successfully, but these errors were encountered: