-
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 |
I'm having the same problem, my use case is that the package is used only internally (private registry) and it depends on git thirdparty repos that are not published. Mirroring those repos on private registry would be a burden, they are more than one hundred between direct dependencies and sub-dependencies, some requires a specific git commit of a crate that is published, so I prefer to insert the deps with a patch on binary's Cargo.toml as a temporary solution, but Rust 1.84.0 broke my pipeline |
In CI and Pre-release workflows. This is due to a change of bahavior in cargo since version See rust-lang/cargo#15059 Will be rolled back after release of distribution '2506'
Another illustration is https://github.com/cpg314/cargo-depot: see this section of the README. |
Our use case is that we use |
Could the people running into this check and report back on whether |
It is a bit tricky to verify my use case since both libcargo and cargo CLI are involved. I believe
So with the current implementation of |
Could those uses be switched to |
I still get same error, which is related to packaging a crate that has as dependency other internal dependencies that are not yet released
|
@morenol could you expand on your use case? |
We have a binary that generates a rust project. Normally, the project generated uses crates.io packages, but while we are developing unstable features we pack the crates and embed them in the binary so the code generator can generate code the references these non released packages |
That could be one solution, yes. However, it then becomes a user problem of my tool, which they need to intervene their broken builds (not too hard but still a churn). |
@morenol, did you mean it still failed with |
This is call in a
|
@morenol |
To summarize,
|
One question continues popping up: why it wasn't a problem for Here is my answer: A lot of packages on crates.io and in the wild are lib only crates. People learn to use Cargo workspaces to separate bins from lib packages for a better dependency management (you can't have bin-only dependency in one package). So I think upon this moment, as |
I think some context to this summary item is missing because I'm not following this.
If we're talking doing weird things for first-party code, then all of this is being done for the sake of releasing a If the process involves common crates.io dependencies, then at least |
Sorry for that. The comment just got updated. Let me know if it is still not clear.
The process can be more complicated when using custom registries or other approaches for sharing code through tarballs. |
How would that be done? Do you have an example? |
It depends on whether you know what you're going to publish beforehand. For example, if you have a let cmd = Command::new("cargo");
cmd.arg("package")
.arg("-Zpackage-workspace")
.arg("--target")
.arg(WASI_TARGET);
for name in names {
cmd.arg("-p").arg(name);
}
let output = cmd.output() |
ok, that seems to work now for me using the |
Problem
#13447 dd698ff has some unintentional consequences:
cargo package
after that 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
— succeededcargo +1.84.0 package -p cargo-test-support --no-verify
— failedPossible Solution(s)
Assume if we have passed the local registry unconditionally, we shouldn't 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: