-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 cannot find renamed dependency from crates-io in package from different registry #14399
Comments
bad case, as in demo repository successful case where dependency was not renamed: |
@arlosi I still get this error with |
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. |
The index entry from the first publish {
"name": "demo-a",
"vers": "0.1.0",
"deps": [
{
"name": "once_cell",
"req": "^1.19.0",
"features": [],
"optional": false,
"default_features": true,
"target": null,
"kind": "normal",
"registry": "https://github.com/rust-lang/crates.io-index",
"package": "renamed_once_cell"
}
],
"cksum": "f82c53b535363edb813ae5fd3413a4b392fea12f96ac401c0d2c90d200d92706",
"features": {},
"yanked": false,
"links": null
} According to the docs {
"deps": [
{
// Name of the dependency.
// If the dependency is renamed from the original package name,
// this is the new name. The original package name is stored in
// the `package` field.
"name": "rand",
// If the dependency is renamed, this is a string of the actual
// package name. If not specified or null, this dependency is not
// renamed.
"package": null,
}
],
} impl From<Dep> for crate::index::Dep {
fn from(source: Dep) -> Self {
Self {
name: source.name,
req: source.version_req,
features: source.features,
optional: source.optional,
default_features: source.default_features,
target: source.target,
kind: source.kind.to_string(),
registry: source.registry,
package: source.explicit_name_in_toml,
}
}
} From https://doc.rust-lang.org/cargo/reference/registry-web-api.html#publish {
// The name of the package.
"name": "foo",
// The version of the package being published.
"vers": "0.1.0",
// Array of direct dependencies of the package.
"deps": [
{
// Name of the dependency.
// If the dependency is renamed from the original package name,
// this is the original name. The new package name is stored in
// the `explicit_name_in_toml` field.
"name": "rand",
// If the dependency is renamed, this is a string of the new
// package name. If not specified or null, this dependency is not
// renamed.
"explicit_name_in_toml": null,
}
],
} From https://doc.rust-lang.org/cargo/reference/registry-index.html
|
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 |
Yes, this is a bug in https://github.com/d-e-s-o/cargo-http-registry/blob/main/src/publish.rs#L95 directly sets the
|
So I should just swap source.name and source.explicit_name_in_toml in cargo-http-registry? |
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
|
@arlosi I ran into another problem. You suggested using |
|
@ehuss After fixing behavior of [dependencies]
renamed_once_cell = { workspace = true, optional = true }
[features]
renamed_once_cell = ["dep:renamed_once_cell"] Demo repository: https://github.com/StackOverflowExcept1on/cargo-bug git clone git@github.com:StackOverflowExcept1on/cargo-bug.git
cd cargo-bug
cargo install --git https://github.com/d-e-s-o/cargo-http-registry.git 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
{
"name": "demo-a",
"vers": "0.1.0",
"deps": [
{
"name": "renamed_once_cell",
"req": "^1.19.0",
"features": [],
"optional": true,
"default_features": true,
"target": null,
"kind": "normal",
"registry": "https://github.com/rust-lang/crates.io-index",
"package": "once_cell"
}
],
"cksum": "2bd501914462eefbe358bc3cdb5f59cb0bcb04740fff4358397c7e2e2bf84019",
"features": {
"renamed_once_cell": []
},
"yanked": false,
"links": null
} |
Problem
Basically I have a crate
demo-a
which requires the dependencyrenamed_once_cell = { version = "1.19.0", package = "once_cell" }
. Thedemo-a
crate is published tomy-registry
, then I publish thedemo-b
crate tomy-registry
. But for some reason cargo doesn't findrenamed_once_cell
on crates-io.Demo repository: https://github.com/StackOverflowExcept1on/cargo-bug
Steps
Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: