Skip to content

Conversation

@moabo3li
Copy link
Contributor

registry-index is an internal-only field that Cargo uses when
packaging crates. It should not appear in user-written Cargo.toml
files as it allows bypassing the documented pattern of using
registry = "name" with .cargo/config.toml.

Fixes #15503

@rustbot rustbot added A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 23, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@moabo3li moabo3li force-pushed the limit_registry_index branch 2 times, most recently from fcbe47d to dfc940d Compare November 25, 2025 03:22
@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@moabo3li moabo3li force-pushed the limit_registry_index branch from dfc940d to ab36df1 Compare November 25, 2025 22:49
Comment on lines 2340 to 2344
// Check if this is a packaged manifest (in target/package or target\package)
// by checking if the path contains the pattern
let path_str: Cow<'_, str> = manifest_ctx.root.to_string_lossy();
let is_packaged_manifest =
path_str.contains("target/package") || path_str.contains("target\\package");
Copy link
Contributor

Choose a reason for hiding this comment

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

cargo package packages are not guaranteed to be at that location (and we have a pending PR for making cargo publish never have them there) and user packages can be at that location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a new read_cargo_generated_manifest function alongside the existing read_manifest. This new function passes a cargo_generated flag down to to_real_manifest_impl. During package verification, the code now uses PathSource::root_cargo_generated_package() to read the extracted manifest with this flag set to true, which allows the internal-only registry-index field to pass validation.
What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned about how invasive this is and the impact of each of these pieces needing to work together just right and how that might hit up against future changes. Compared to the risks of not erroring with registry-index, I'm unsure if this adds up.

I opened #15503 and some times we don't know where a change will go until it happens. I am very much grateful for the work you put into this and what we've learned from this. I'd like to get a second opinion from @weihanglo before deciding whether to stop work or continue this. If we decide not to move forward with this, I am sorry for all of the time you put into this for this not actually getting in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, thank you for the review.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, while this seems working well (and thanks for your efforts!), it is indeed invasive and perhaps fragile as the logic touches too many different component.

I wonder if we should just a bigger warning in cargo-util-schemas doc, and saying that there is no stability guarantee. Something like
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if we should just a bigger warning in cargo-util-schemas doc, and saying that there is no stability guarantee. Something like

Ok, I can open another PR for that if you’d like, and do this.

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

Labels

A-manifest Area: Cargo.toml issues A-workspaces Area: workspaces Command-package Command-read-manifest 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.

Limit registry-index dependency field to registry sources only

4 participants