Only ignore dev-dependencies in dependency order if they have no version

This commit is contained in:
Joe Neeman 2025-05-01 13:25:24 +07:00
parent 54448a1a19
commit faf7329c4f
2 changed files with 15 additions and 10 deletions

View File

@ -406,9 +406,14 @@ fn local_deps<T>(packages: impl Iterator<Item = (Package, T)>) -> LocalDependenc
for (pkg, _payload) in packages.values() {
graph.add(pkg.package_id());
for dep in pkg.dependencies() {
// Ignore local dev-dependencies because they aren't needed for intra-workspace
// lockfile generation or verification as they get stripped on publish.
if dep.kind() == DepKind::Development || !dep.source_id().is_path() {
// We're only interested in local (i.e. living in this workspace) dependencies.
if !dep.source_id().is_path() {
continue;
}
// If local dev-dependencies don't have a version specified, they get stripped
// on publish so we should ignore them.
if dep.kind() == DepKind::Development && !dep.specified_req() {
continue;
};

View File

@ -5865,15 +5865,15 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
[PACKAGING] main v0.0.1 ([ROOT]/foo/main)
[UPDATING] crates.io index
[ERROR] failed to prepare local package for uploading
Caused by:
no matching package named `dev_dep` found
location searched: crates.io index
required by package `main v0.0.1 ([ROOT]/foo/main)`
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[VERIFYING] dev_dep v0.0.1 ([ROOT]/foo/dev_dep)
[COMPILING] dev_dep v0.0.1 ([ROOT]/foo/target/package/dev_dep-0.0.1)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[VERIFYING] main v0.0.1 ([ROOT]/foo/main)
[COMPILING] main v0.0.1 ([ROOT]/foo/target/package/main-0.0.1)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.with_status(101)
.run();
}