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

sparse registry: incorrect SourceID URL serialization for alt registries #10963

Closed
ehuss opened this issue Aug 9, 2022 · 0 comments · Fixed by #11177
Closed

sparse registry: incorrect SourceID URL serialization for alt registries #10963

ehuss opened this issue Aug 9, 2022 · 0 comments · Fixed by #11177
Labels
A-sparse-registry Area: http sparse registries C-bug Category: bug

Comments

@ehuss
Copy link
Contributor

ehuss commented Aug 9, 2022

Problem

When using sparse-registry with an alternative registry, the SourceID is rendered as registry+sparse+https://.... That doesn't look correct to me, I would assume it should be sparse+https://….

Steps

The following cargo test illustrates the example where the SourceID gets shown to the user.

#[cargo_test]
fn sparse_alt_registry() {
    let _server = RegistryBuilder::new().http_index().alternative().build();

    let p = project()
        .file(
            "Cargo.toml",
            r#"
                [project]
                name = "foo"
                version = "0.0.1"
                authors = []

                [dependencies]
                bar = {registry="alternative", version=">= 0.0.0"}
            "#,
        )
        .file("src/main.rs", "fn main() {}")
        .build();

    Package::new("bar", "0.0.1").alternative(true).publish();

    cargo_http(&p, "build --message-format=json")
        // SourceID issue is here...
        .with_stderr("")
        .run();
}

Here the JSON will have things like "package_id":"bar 0.0.1 (registry+sparse+http://127.0.0.1:61095/index/)"

Possible Solution(s)

The issue is that the serialization code here doesn't know anything about sparse registries.

My intuition is that SourceKind should have another variant to track sparse indexes (instead of reusing SourceKind::Registry). This is related to the comment here about it being a little strange that sparse+ is being tacked into the URL.

Notes

I would also like to see more tests for alt registries using sparse registries.

Version

cargo 1.64.0-nightly (85b500cca 2022-07-24)
release: 1.64.0-nightly
commit-hash: 85b500ccad8cd0b63995fd94a03ddd4b83f7905b
commit-date: 2022-07-24
host: x86_64-apple-darwin
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.79.1 (sys:0.4.55+curl-7.83.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.4.0 [64-bit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sparse-registry Area: http sparse registries C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant