-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(resolver): Stabilize min-publish-age #17335
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
epage marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -153,11 +153,13 @@ rpath = false # Sets the rpath linking option. | |||||||||||||||||||||||||||||||||
| [resolver] | ||||||||||||||||||||||||||||||||||
| lockfile-path = "…" # Overrides the path used for | ||||||||||||||||||||||||||||||||||
| incompatible-rust-versions = "allow" # Specifies how resolver reacts to these | ||||||||||||||||||||||||||||||||||
| incompatible-publish-age = "deny" # Specifies how resolver treats recently published versions | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| [registries.<name>] # registries other than crates.io | ||||||||||||||||||||||||||||||||||
| index = "…" # URL of the registry index | ||||||||||||||||||||||||||||||||||
| token = "…" # authentication token for the registry | ||||||||||||||||||||||||||||||||||
| credential-provider = "cargo:token" # The credential provider for this registry. | ||||||||||||||||||||||||||||||||||
| min-publish-age = "7 days" # Override `registry.global-min-publish-age` for this registry | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| [registries.crates-io] | ||||||||||||||||||||||||||||||||||
| protocol = "sparse" # The protocol to use to access crates.io. | ||||||||||||||||||||||||||||||||||
|
|
@@ -167,6 +169,7 @@ default = "…" # name of the default registry | |||||||||||||||||||||||||||||||||
| token = "…" # authentication token for crates.io | ||||||||||||||||||||||||||||||||||
| credential-provider = "cargo:token" # The credential provider for crates.io. | ||||||||||||||||||||||||||||||||||
| global-credential-providers = ["cargo:token"] # The credential providers to use by default. | ||||||||||||||||||||||||||||||||||
| global-min-publish-age = "7 days" # The time span allowed for registry packages to use by default. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| [source.<name>] # source definition and replacement | ||||||||||||||||||||||||||||||||||
| replace-with = "…" # replace this source with the given named source | ||||||||||||||||||||||||||||||||||
|
|
@@ -1161,6 +1164,23 @@ See the [resolver](resolver.md#rust-version) chapter for more details. | |||||||||||||||||||||||||||||||||
| > - `allow` is supported on any version | ||||||||||||||||||||||||||||||||||
| > - `fallback` is respected as of 1.84 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #### `resolver.incompatible-publish-age` | ||||||||||||||||||||||||||||||||||
| * Type: string | ||||||||||||||||||||||||||||||||||
| * Default: `"deny"` | ||||||||||||||||||||||||||||||||||
| * Environment: `CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| When resolving the version of a dependency, | ||||||||||||||||||||||||||||||||||
| specify the behavior for versions with a `pubtime` (if present) | ||||||||||||||||||||||||||||||||||
| that is incompatible with the configured `min-publish-age`. | ||||||||||||||||||||||||||||||||||
| Values include: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - `allow`: treat pubtime-incompatible versions like any other version | ||||||||||||||||||||||||||||||||||
| - `deny`: ignore pubtime-incompatible versions unless they already exist in the lock file | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| See the [resolver](resolver.md#publish-age) chapter for more details. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| > **MSRV:** Respected as of 1.100+ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### `[registries]` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| The `[registries]` table is used for specifying additional [registries]. It | ||||||||||||||||||||||||||||||||||
|
|
@@ -1200,6 +1220,26 @@ If the value exists in the [`[credential-alias]`](#credential-alias) table, the | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| See [Registry Authentication](registry-authentication.md) for more information. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #### `registries.<name>.min-publish-age` | ||||||||||||||||||||||||||||||||||
| * Type: string | ||||||||||||||||||||||||||||||||||
| * Default: [`registry.global-min-publish-age`](#registryglobal-min-publish-age) | ||||||||||||||||||||||||||||||||||
| * Environment: `CARGO_REGISTRIES_<name>_MIN_PUBLISH_AGE` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Specifies the minimum timespan since a version's `pubtime` that may be | ||||||||||||||||||||||||||||||||||
| considered for [`resolver.incompatible-publish-age`] for packages from this | ||||||||||||||||||||||||||||||||||
| registry. If not set, [`registry.global-min-publish-age`](#registryglobal-min-publish-age) will be used. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Will be ignored if the registry does not support this. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| It supports the following values: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - An integer followed by "seconds", "minutes", "hours", "days", "weeks", or "months" | ||||||||||||||||||||||||||||||||||
| - `"0"` to allow all packages | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Generally, `"0"`, `"N days"`, and `"N weeks"` will be used. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| > **MSRV:** Respected as of 1.100+ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #### `registries.crates-io.protocol` | ||||||||||||||||||||||||||||||||||
| * Type: string | ||||||||||||||||||||||||||||||||||
| * Default: `"sparse"` | ||||||||||||||||||||||||||||||||||
|
|
@@ -1275,6 +1315,25 @@ referenced here by its alias. | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| See [Registry Authentication](registry-authentication.md) for more information. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #### `registry.global-min-publish-age` | ||||||||||||||||||||||||||||||||||
| * Type: string | ||||||||||||||||||||||||||||||||||
| * Default: `"0"` | ||||||||||||||||||||||||||||||||||
| * Environment: `CARGO_REGISTRY_GLOBAL_MIN_PUBLISH_AGE` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Specifies the global minimum timespan since a version's `pubtime` that it may | ||||||||||||||||||||||||||||||||||
| be considered for [`resolver.incompatible-publish-age`] for packages. | ||||||||||||||||||||||||||||||||||
| If `min-publish-age` is not set for a specific registry using | ||||||||||||||||||||||||||||||||||
| `registries.<name>.min-publish-age`, Cargo will use this minimum publish age. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| It supports the following values: | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - An integer followed by "seconds", "minutes", "hours", "days", "weeks", or "months" | ||||||||||||||||||||||||||||||||||
| - `"0"` to allow all packages | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Generally, `"0"`, `"N days"`, and `"N weeks"` will be used. | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+1330
to
+1333
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The definition of this friendly format is here. They are all fixed seconds. And both singular and plural forms are supported. Lines 28 to 35 in 7456cea
We can consider it, though extending this would also need to extend pre-existing That said, I saw uv has done a great job documenting this. We probably could polish ours as well.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Would appreciate if you dont mind opening a new issue for it! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Glad to see it. No problem.
The above logic is shared by both options, isn't it?
I see. You can go ahead with the current logic.
I hope we can adopt it in both options in the future. Sorry for having bothered you.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All good points. No worries and thank you! |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| > **MSRV:** Respected as of 1.100+ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ### `[source]` | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| The `[source]` table defines the registry sources available. See [Source | ||||||||||||||||||||||||||||||||||
|
|
@@ -1562,3 +1621,4 @@ Report progress to the terminal emulator for display in places like the task bar | |||||||||||||||||||||||||||||||||
| [crates.io]: https://crates.io/ | ||||||||||||||||||||||||||||||||||
| [target triple]: ../appendix/glossary.md#target '"target" (glossary)' | ||||||||||||||||||||||||||||||||||
| [`<triple>`]: ../appendix/glossary.md#target '"target" (glossary)' | ||||||||||||||||||||||||||||||||||
| [`resolver.incompatible-publish-age`]: config.md#resolverincompatible-publish-age | ||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before diving into other aspects of the stabilization, have we got any feedback for this using in CI / production?
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I know of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I did not see this answered, I can share my testing here.
I tested the min-publish-age feature as a system-wide default on Amazon Linux 2023 (x86_64 + arm64) VMs with rustc/cargo 1.100.0-nightly (2026-08-27).
Setup
Findings
cargo build --lockedproduces identical Cargo.lock with and without the cooldown. I diffed Cargo.lock byte-for-byte from Firecracker builds with vs without cooldown..cargo/config.toml with global-min-publish-age = "0 days"overrides the system default.cargo update -p <crate>upgrades to the newest cooldown-compatible version.CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allowwas accepted on this nightly for bypassing the policy.Locking 7 packages to highest Rust 1.100.0-nightly compatible versions as of 24 hours ago-- having a UTC timestamp would be better if it's in logs, but that's fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly the kind of real world testing I was looking for. Thanks a lot for taking time to test and document it!