Skip to content

Cargo vendor: add source rewriting for private registries included in deps - #14716

Open
P-E-Meunier wants to merge 1 commit into
rust-lang:masterfrom
P-E-Meunier:master
Open

P-E-Meunier wants to merge 1 commit into
rust-lang:masterfrom
P-E-Meunier:master

Conversation

@P-E-Meunier

Copy link
Copy Markdown

In the case where the exact same dependency (hash-wise) is supplied by two different registries, Cargo.lock keeps only one sources. However, in that case, the output of cargo vendor contains only the registry from Cargo.lock, which isn't enough to compile with --offline.

This PR fixes this by adding the dependencies' registries of all vendored packages to the output of cargo vendor.

@rustbot

rustbot commented Oct 22, 2024

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added Command-vendor S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 22, 2024
@P-E-Meunier
P-E-Meunier force-pushed the master branch 2 times, most recently from 8017eaa to 8e9e0ce Compare October 22, 2024 17:41
… deps

In the case where the exact same dependency is supplied by two different registries, Cargo.lock keeps only one. However, in that case, the output of `cargo vendor` contains only the registry from Cargo.lock, which isn't enough to compile with `--offline`.

This commit adds the dependencies' registries of all vendored packages to the output of `cargo vendor`.

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request. Could you provide a bug reproduction and open an issue first? Without that it is not immediately clear what this patch is for. That workflow is also encouraged in Cargo Contributor Guide.

Comment thread src/cargo/ops/vendor.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contributing guide also encourages writing tests. Tests added before the commit of the actual fix can be seen as an MRE, letting people understand the problematic behavior indeed exists. See https://doc.crates.io/contrib/process/working-on-cargo.html#submitting-a-pull-request

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only happens when you have two copies of the same private registry, which is hard to test. But I'd of course welcome guidance on that if this is implemented somewhere.

@P-E-Meunier

Copy link
Copy Markdown
Author

Thanks for the review, I added a detailed explanation in a new issue.

@P-E-Meunier

Copy link
Copy Markdown
Author

Minimal reproduction: https://github.com/P-E-Meunier/cargo-vendor-test

@rustbot

rustbot commented Mar 4, 2025

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly 29f8d03) made this pull request unmergeable. Please resolve the merge conflicts.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Command-vendor S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants