rust-lang/cargo · error
packages downloaded
Error message
packages downloaded
What it means
This panic is in build_unit_features() during compilation. It calls package_set.get_one(dep_id).expect("packages downloaded") to check if a dependency is a proc-macro. The invariant is that by the time feature resolution runs, all packages in the dependency graph have already been downloaded and are available in the PackageSet. If get_one() returns an error (package not found), the expect panics.
Source
Thrown at src/ops/cargo_compile/mod.rs:1228
.activated_features(package_id, FeaturesFor::NormalOrDev)
.iter()
.map(|s| s.to_string())
.collect();
// Include features enabled for use by dependencies so targets can also use them with the
// required-features field when deciding whether to be built or skipped.
let filtered_deps = PackageSet::filter_deps(
package_id,
resolve_with_overrides,
has_dev_units,
requested_kinds,
target_data,
force_all_targets,
);
for (dep_id, deps) in filtered_deps {
let is_proc_macro = package_set
.get_one(dep_id)
.expect("packages downloaded")
.proc_macro();
for dep in deps {
let features_for = FeaturesFor::from_for_host(is_proc_macro || dep.is_build());
for feature in resolved_features
.activated_features_unverified(dep_id, features_for)
.unwrap_or_default()
{
features.insert(format!("{}/{}", dep.name_in_toml(), feature));
}
}
}
features
}
View on GitHub (pinned to 0e07a15537)
Solutions
- Run cargo fetch to ensure all packages are downloaded: cargo fetch.
- Clear the cargo registry cache and re-download: rm -rf ~/.cargo/registry && cargo fetch.
- Regenerate Cargo.lock: rm Cargo.lock && cargo generate-lockfile.
- Check network connectivity to the registry and retry the build.
Defensive patterns
Strategy: retry
Validate before calling
// Before compiling, ensure all packages are downloaded
cargo fetch
// Verify registry cache is populated
let registry_cache = dirs::home_dir().unwrap().join(".cargo/registry");
if !registry_cache.exists() {
eprintln!("registry cache missing; run cargo fetch");
} Prevention
- Run cargo fetch before building in CI or offline environments.
- Clear and re-download the registry cache if corrupted: rm -rf ~/.cargo/registry && cargo fetch.
- Regenerate Cargo.lock if dependency metadata is inconsistent.
- Check network connectivity to the registry before building.
When it happens
Trigger: Compiling a project where a dependency in the resolved graph was never downloaded — this could happen if the download step was skipped, if the PackageSet was constructed incompletely, or if a dependency was added to the resolution after the download phase.
Common situations: Corrupted or incomplete cargo cache (~/.cargo/registry); a cargo internal bug where feature resolution runs before package downloads complete; a network interruption during cargo fetch that was not properly detected; using cargo as a library with an incompletely populated PackageSet.
Related errors
- latest always has a source
- source should be resolved before here
- already a valid dependency
- remote registries must have config
- artifact-dir was not locked
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/117f5d4e7922a2ce.json.
Report an issue: GitHub.