[registry] vs [registries] per-key semantics - #100
Closed
weihanglo wants to merge 2 commits into
Closed
Conversation
To ensure dependencies have had a chance to be scanned, a user can set:
```toml
[registry]
global-min-publish-age = "7 days"
```
To force a critical update through, a user can
```console
$ CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo update -p foo
```
That will be preserved within the lockfile.
To ensure users can observe what is going on and address concerns,
- Locking messages notify of:
- That min-publish-age is in use and what the age is if there is a
single one
- a newer, unpicked version is available and its age
- a version is being used that is incompatible with min-publish-age
(either through `allow` or an unchange dep shown through `-v`)
- Error messages notify of:
- a newer, unpicked version is available and its age
- a compatible version requirement to downgrade to
- how to use `CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE`
Items from the tracking issue:
- `deny` precedence between this and `incompatible-rust-version`: we can
always adjust this over time
- the `registry.min-publish-age` / `registries.*.min-publish-age` precedence rule: mimics credential providers
- `cargo install` behavior
- there was some confusion over what was being stabilized due to edits
that happened during the FCP that weren't noticed
- `resolver` is defined as not affecting `cargo install` which this
preserves, just like `incompatible-rust-version`
- `cargo update --breaking`: this feature is being stabilized first and
the other is being considered for removal (rust-lang#17333)
Fixes rust-lang#17009
weihanglo
marked this pull request as draft
August 11, 2026 04:09
[registry] vs [registries] per-key semantics
# `[registry]` vs `[registries.<name>]` per-key semantics Review notes for [rust-lang#17335] (min-publish-age stabilization), comparing how each config key behaves across the two tables. Verified against PR head `7b009184` with repro tests in `tests/testsuite/registry_table_confusion.rs` and the PR's own `tests/testsuite/min_publish_age.rs`. [rust-lang#17335]: rust-lang#17335 (comment) | Key | `[registry]` | `[registries.crates-io]` | `[registries.<alt>]` | Evidence | |---|---|---|---|---| | `token` | works for crates.io; does **not** follow `registry.default` | **silently ignored** (config and `CARGO_REGISTRIES_CRATES_IO_TOKEN` env) | works | `registries_crates_io_token_ignored_for_crates_io`, `registry_token_does_not_follow_registry_default` | | `credential-provider` | works for crates.io | **silently ignored** | works | `registries_crates_io_credential_provider_ignored` | | `secret-key` / `secret-key-subject` | works for crates.io | silently ignored (same code path as `token`) | works | code: `src/util/auth/mod.rs:212` returns `[registry]` for crates.io before any name lookup | | `min-publish-age` (new) | crates.io only; ignored for alt registries even with `registry.default` pointing at them | **honored; overrides `registry.min-publish-age`** | honored | `registry_alt_ignores_min_publish_age`, `registries_crates_io_overrides_registry_default` | | `global-min-publish-age` (new) | fallback for **all** registries | silently ignored (not a `RegistryConfig` field) | silently ignored | code: `src/context/schema.rs:530` | | `protocol` | silently ignored (not a `GlobalRegistryConfig` field) | honored | parsed but unused (`_protocol`) | code: `SourceId::crates_io_is_sparse` reads `registries.crates-io.protocol` only | | `index` | hard error: "no longer supported" | silently ignored (`SourceId::alt_registry` short-circuits `crates-io`) | required; defines the registry | code: `check_registry_index_not_set`, `src/workspace/source_id.rs:296` | | `default` | selects target registry for `publish`/`login`/`owner`/`yank` when `--registry`/`--index` absent | silently ignored | n/a | code: `src/util/command_prelude.rs:919` | | `global-credential-providers` | fallback providers for **all** registries | silently ignored | silently ignored | code: `src/util/auth/mod.rs:57` | Key asymmetries: * `min-publish-age` is the first key where `[registries.crates-io]` both works and overrides its `[registry]` counterpart; for the auth keys, `[registries.crates-io]` is dead config. * Auth resolves crates.io **by URL first** (`is_crates_io()`, `src/util/auth/mod.rs:212`); min-publish-age resolves **by name first** (`alt_registry_key()`, `src/resolver/version_prefs.rs:279`). A named mirror of crates.io's index gets `[registry]` credentials but `registries.<mirror>.min-publish-age`. * `registries.<name>.global-min-publish-age` and `registry.protocol` are silent no-ops — the same "subtle `s` distinction" concern raised in [rust-lang#12334](rust-lang#12334 (comment)).
weihanglo
force-pushed
the
registry-table
branch
from
August 12, 2026 01:23
65f5cea to
b0af8c6
Compare
weihanglo
commented
Aug 12, 2026
Owner
Author
There was a problem hiding this comment.
Tests showing the confusion and inconsistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclosure: Generated by LLM. Not human-reviewed yet, but every table claim is backed by an executed test (21/21 passing against rust-lang#17335 head
7b009184).[registry]vs[registries.<name>]per-key semanticsReview notes for rust-lang/cargo#17335 (min-publish-age stabilization),
comparing how each config key behaves across the two tables.
Verified against PR head
7b009184:every cell below is backed by a passing test in
tests/testsuite/registry_table_confusion.rs(this branch)or the PR's own
tests/testsuite/min_publish_age.rs."warned" below means cargo emits
[WARNING] unused config key ...and ignores the value;"silent no-op" means the value is accepted without any diagnostic —
these are exactly the keys that exist as struct fields
shared between
GlobalRegistryConfigandRegistryConfigbut are never consulted for that registry.
[registry][registries.crates-io][registries.<alt>]tokenregistry.defaultCARGO_REGISTRIES_CRATES_IO_TOKENenv)registries_crates_io_token_ignored_for_crates_io,registry_token_used_for_crates_io,registry_token_does_not_follow_registry_defaultcredential-providerregistries_crates_io_credential_provider_ignored,registry_credential_provider_used_for_crates_iosecret-key/secret-key-subjectregistries_crates_io_secret_key_ignored,registry_secret_key_used_for_crates_ioglobal-credential-providersregistry_global_credential_providers_used_for_crates_io,registries_crates_io_global_credential_providers_ignored,registries_alt_global_credential_providers_ignoredmin-publish-age(new)registry.defaultpointing at themregistry.min-publish-ageregistry_alt_ignores_min_publish_age,registries_crates_io_overrides_registry_default,registries_alt(all inmin_publish_age.rs)global-min-publish-age(new)registry_default_overrides_global(min_publish_age.rs),registries_crates_io_global_min_publish_age_ignored,registries_alt_global_min_publish_age_ignoredprotocolregistry_protocol_ignored,registries_crates_io_protocol_honored,registries_alt_protocol_parsed_but_unusedindexSourceId::alt_registryshort-circuitscrates-io; a bogus URL is never even read)registry_index_hard_error,registries_crates_io_index_ignoreddefaultpublish/login/owner/yankwhen--registry/--indexabsentregistry_token_does_not_follow_registry_default,registries_crates_io_default_ignoredKey asymmetries:
min-publish-ageis the first key where[registries.crates-io]both worksand overrides its
[registry]counterpart;for the auth keys (
token,credential-provider,secret-key),[registries.crates-io]is dead config —and silently dead, because those keys are valid
RegistryConfigfieldsand therefore dodge the unused-key warning that catches typos like
registries.<name>.global-min-publish-age.(
is_crates_io(),src/util/auth/mod.rs:212);min-publish-age resolves by name first
(
alt_registry_key(),src/resolver/version_prefs.rs:279).Test-verified with a named registry whose index is crates.io's URL:
cargo publish --registry mirrorignoresregistries.mirror.token,prints the crates.io-flavored "no token found, please run
cargo login"hint, and then happily publishes to
mirroronceregistry.tokenis set(
mirror_of_crates_io_auth_resolves_by_url).registries.mirror.min-publish-age(
mirror_of_crates_io_min_publish_age_resolves_by_name),and when that is unset, the "crates.io-only"
registry.min-publish-ageleaks onto it through the URL match
(
registry_min_publish_age_applies_to_crates_io_url_mirror) —the very key that
registry_alt_ignores_min_publish_ageproves is notapplied to a registry with a non-crates.io URL.
with this PR, resolve-time commands emit each unused-key warning twice
(e.g.
unused config key registry.protocolappears both before and after[UPDATING]inregistry_protocol_ignored),suggesting the registry tables are deserialized more than once per command.