-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Not planned
Not planned
Copy link
Description
Problem
Basically I have a crate demo-a
which requires the dependency renamed_once_cell = { version = "1.19.0", package = "once_cell" }
. The demo-a
crate is published to my-registry
, then I publish the demo-b
crate to my-registry
. But for some reason cargo doesn't find renamed_once_cell
on crates-io.
demo-a v0.1.0 (/mnt/tmpfs/cargo-bug/demo-a) (my-registry)
└── once_cell v1.19.0 (crates-io)
demo-b v0.1.0 (/mnt/tmpfs/cargo-bug/demo-b) (my-registry)
└── demo-a v0.1.0 (/mnt/tmpfs/cargo-bug/demo-a) (my-registry)
└── once_cell v1.19.0 (crates-io)
Demo repository: https://github.com/StackOverflowExcept1on/cargo-bug
Steps
git clone git@github.com:StackOverflowExcept1on/cargo-bug.git
cd cargo-bug
cargo install cargo-http-registry
# in the background
rm -rf /tmp/my-registry && cargo-http-registry --addr 127.0.0.1:35503 /tmp/my-registry &
cargo publish -p demo-a && cargo publish -p demo-b
fg
Ctrl+C
error: failed to verify package tarball
Caused by:
no matching package named `renamed_once_cell` found
location searched: registry `crates-io`
required by package `demo-a v0.1.0 (registry `my-registry`)`
... which satisfies dependency `demo-a = "^0.1.0"` of package `demo-b v0.1.0 (/mnt/tmpfs/cargo-bug/target/package/demo-b-0.1.0)`
Possible Solution(s)
No response
Notes
No response
Version
cargo 1.80.1 (376290515 2024-07-16)
Activity
[-]Cargo cannot find renamed dependency with crates-io in package from different registry[/-][+]Cargo cannot find renamed dependency from crates-io in package from different registry[/+]StackOverflowExcept1on commentedon Aug 14, 2024
bad case, as in demo repository
bad-case.txt
successful case where dependency was not renamed:
successful-case.txt
arlosi commentedon Aug 14, 2024
I believe this is a duplicate of #14321. The fix is via #14325.
Could you verify with the current beta or nightly (including the publishing step, which is where the problem occurs)?
StackOverflowExcept1on commentedon Aug 14, 2024
@arlosi I still get this error with
cargo 1.82.0-nightly (0d8d22f83 2024-08-08)
epage commentedon Aug 14, 2024
The bug is in the data Cargo sends to the non-crates.io registry. If its already in the registry, upgrading won't fix it. The package will need to be re-published.
StackOverflowExcept1on commentedon Aug 14, 2024
@epage I always run an empty registry and even with it it reproduces on 0d8d22f.
epage commentedon Aug 14, 2024
The index entry from the first publish
According to the docs
from https://github.com/d-e-s-o/cargo-http-registry/blob/651d22e254a0f7712e5eba9592ff68e69d1a85c9/src/publish.rs#L84C1-L98C2
From https://doc.rust-lang.org/cargo/reference/registry-web-api.html#publish
From https://doc.rust-lang.org/cargo/reference/registry-index.html
epage commentedon Aug 14, 2024
From the above, this looks to be a bug in https://github.com/d-e-s-o/cargo-http-registry
Of course, this would be less likely to happen if we had the types and the type conversions published in
cargo-util-schemas
arlosi commentedon Aug 14, 2024
Yes, this is a bug in
cargo-http-registry
https://github.com/d-e-s-o/cargo-http-registry/blob/main/src/publish.rs#L95 directly sets the
package
field in the index toexplicit_name_in_toml
, which is incorrect. One is the original name, the other is the renamed-name.explicit_name_in_toml
docs:package
docs:StackOverflowExcept1on commentedon Aug 14, 2024
So I should just swap source.name and source.explicit_name_in_toml in cargo-http-registry?
arlosi commentedon Aug 14, 2024
Only if the dependency is renamed. You can see how Cargo does it in our mock registry for tests:
cargo/crates/cargo-test-support/src/registry.rs
Lines 1198 to 1201 in 3a20ea7
StackOverflowExcept1on commentedon Aug 15, 2024
@arlosi I ran into another problem. You suggested using
cargo-util-schemas
, but now I see that my problem is not with the renamed dependency, but with the missingfeatures2
key (when usingdep:renamed-feature
). However, I couldn't findfeatures2
in either the documentation https://doc.rust-lang.org/cargo/reference/registry-web-api.html#publish or thecargo-util-schemas
crate.ehuss commentedon Aug 15, 2024
features2
is only required by crates.io. Other registries should not bother with it. It is only for backwards compatibility. It also only appears in the index, not the publish API. This is documented in https://doc.rust-lang.org/cargo/reference/registry-index.html#json-schema.StackOverflowExcept1on commentedon Aug 15, 2024
@ehuss After fixing behavior of
cargo-http-registry
I still have problem like #14148, but now withdep:renamed_once_cell
. Now publishing cratedemo-a
does not happen after 60 seconds.Demo repository: https://github.com/StackOverflowExcept1on/cargo-bug
/tmp/my-registry/de/mo/demo-a
pkg
to be available in registrycargo-http-registry
d-e-s-o/cargo-http-registry#61