Skip to content
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

Dependency listed incorrectly if it has aliased #27

Open
cr0sh opened this issue Oct 14, 2021 · 0 comments
Open

Dependency listed incorrectly if it has aliased #27

cr0sh opened this issue Oct 14, 2021 · 0 comments

Comments

@cr0sh
Copy link

cr0sh commented Oct 14, 2021

Hi @moriturus, thanks for open-sourcing this useful project. It works very smoothly(especially with Docker containers :D), but I believe there is a subtle bug:

When a package to be published has a dependency with package field, ktra places it into index wrongly.

Steps to reproduce:

  1. Create a dummy package(say foo)
[package]
name = "foo"
version = "0.1.0"
edition = "2018"


[dependencies]
hello-world = { version = "*", package = "hello" }
  1. Publish it
  2. Referring Cargo reference, the added index should have dependency with fields "name": "hello-world", "package": "hello", but two fields are interchanged. This causes confusing dependency resolution failure on cargo fetch(no matching package), although cargo search on ktra registry returns the exact package.

To resolve, Into<Dependency> impl of MetadataDependency should swap two fields.

ktra/src/models.rs

Lines 19 to 34 in 8a14cd2

impl Into<Dependency> for MetadataDependency {
#[tracing::instrument(skip(self))]
fn into(self) -> Dependency {
Dependency {
name: self.name,
req: self.version_req,
features: self.features,
optional: self.optional,
default_features: self.default_features,
target: self.target,
kind: self.kind,
registry: self.registry,
package: self.explicit_name_in_toml,
}
}
}

(possibly fixing) change:

        Dependency {
            name: self
                .explicit_name_in_toml
                .clone()
                .unwrap_or_else(|| self.name.clone()),
            req: self.version_req,
            features: self.features,
            optional: self.optional,
            default_features: self.default_features,
            target: self.target,
            kind: self.kind,
            registry: self.registry,
            package: if self.explicit_name_in_toml.is_some() {
                Some(self.name)
            } else {
                None
            },
        }

Thanks in advance!

@cr0sh cr0sh changed the title Dependency listed incorrectly if it has aliased name Dependency listed incorrectly if it has aliased Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant