-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo package --no-verify
fails if a package's version req is too high for the registry (but works locally)
#15059
Comments
So this is a problem that existed before 54df3c7 but only for some crates. Now all see it, right? |
Yeah I believe it was only bugging for packages having |
@Eh2406 our resolve call is cargo/src/cargo/ops/cargo_package/mod.rs Lines 655 to 664 in 54df3c7
Is there a way to say "prefer existing but don't lock them? Would |
In terms of a swift fix: How stable is |
I'm not sure how that would fix it. We wouldn't be putting the package into |
More like Cargo automatically publishes unpublished dependencies crates when needed to TmpRegistry before building the lock? |
I suspect getting it right to sometimes publish to if we feel the need to backport to beta, a revert is likely the best route. If not, we should at least understand what it would take on the resolver side. |
We are running into same issue. Can this is be reverted? |
cargo package
failed if a package contains unpublished local dependenciescargo package --no-verify
fails if a package's version req is too high for the registry (but works locally)
I cannot reproduce this if I bump the package's version but don't bump the version requirement. I also missed the detail that This means that The documentation for
I think this still leaves room for other verification. Historically, we've done some registry and dependency verification and we recently added "is this published?" (#14448). cargo/src/cargo/ops/registry/publish.rs Lines 96 to 139 in 54df3c7
Its also not clear to me why you would be publishing packages without dependencies present. Is this a workaround for #4242? We already have a method for this for some cases (leaving off versions for dev-dependencies). If there is a case that doesn't cover, it would be good to make sure its reported in #4242. |
Note that this is about There are workflows packaging source code into This Cargo-flavored test works in 1.83 but fails in 1.84.
#[cargo_test]
fn unpublished_dependency() {
Package::new("dep", "0.1.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "main"
version = "0.0.1"
edition = "2015"
[dependencies]
dep = { path = "dep", version = "0.1.1" }
"#,
)
.file("src/lib.rs", "")
.file(
"dep/Cargo.toml",
r#"
[package]
name = "dep"
version = "0.1.1"
edition = "2015"
"#,
)
.file("dep/src/lib.rs", "")
.build();
p.cargo("package --package main --no-verify --no-metadata")
.with_status(101)
.with_stderr_data(str![[r#"
[PACKAGING] main v0.0.1 ([ROOT]/foo)
[UPDATING] `dummy-registry` index
[ERROR] failed to prepare local package for uploading
Caused by:
failed to select a version for the requirement `dep = "^0.1.1"`
candidate versions found which didn't match: 0.1.0
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
required by package `main v0.0.1 ([ROOT]/foo)`
perhaps a crate was updated and forgotten to be re-vendored?
"#]])
.run();
} |
That seems like a very limited workflow as it only worked if the crates had no |
@sehz could you help us understand more about your use case? I feel like there are reasons to keep the new behavior but I want to also better understand your situation to better understand how compelling the old behavior is. |
We are building development version of binary which depends on unpublished version of crates for obvious reason. The binary is not in the same repo as other crates. So we packaged unpublished version of crates so it can be refer by binary crate. |
Would be ok to have previous behavior with flag. |
Could you go into more detail. I feel I'm not quite getting why |
Problem
#13447 dd698ff has some unintentional consequences:
cargo package
after than generates a lockfile also when packaging libraries.However, if the crate being packaged depends on some unpublished dependencies. When generating the lockfile Cargo then can't find unpublished deps on registry index, so it bailed out.
Steps
This could be simplly reproduced in rust-lang/cargo as of today (2025-01-13)
99.99.99
cargo +1.83.0 package -p cargo-test-support --no-verify
— expect to succeedcargo +1.84.0 package -p cargo-test-support --no-verify
— expect to failPossible Solution(s)
Assume if we have passed the local registry unconditionally, we should have the issue today.
cargo/src/cargo/ops/cargo_package/mod.rs
Lines 219 to 225 in f15df8f
Version
cargo 1.84.0 (66221abde 2024-11-19)
cargo 1.86.0-nightly (088d49608 2025-01-10)
The text was updated successfully, but these errors were encountered: