Hint that a new Rust release may be available#4869
Conversation
| return Ok(()); | ||
| } | ||
|
|
||
| cfg.settings_file.with_mut(|s| { |
There was a problem hiding this comment.
I still think it might be harmful to write this in settings_file; I'd suggest if we were to write the timestamp to a file, it should be an individual one so that under XDG we can put it under ~/.local/state/rustup/ whereas the settings file should clearly be under ~/.config/rustup/.
cc @Cloud0310 for potential interaction/collaboration regarding XDG.
There was a problem hiding this comment.
Agreed.
Is there anywhere I should look regarding the XDG paths in the code, or should I leave this refactoring (i.e., settings.toml -> XDG) until after the XDG patch lands?
Happy to collaborate with @Cloud0310 on this!
There was a problem hiding this comment.
@FranciscoTGouveia I don't think it should be in the settings.toml in the first place (it's not user configuration).
For the moment I'll say just write it as a new file under $RUSTUP_HOME such as state.toml and the XDG change should handle the rest.
0679b12 to
f9a9d91
Compare
This comment has been minimized.
This comment has been minimized.
f9a9d91 to
bebc2bf
Compare
| pub(crate) const WARN_COMPLETE_PROFILE: &str = "downloading with complete profile isn't recommended unless you are a developer of the rust language"; | ||
| const RELEASE_CYCLE_DAYS: i64 = 42; | ||
| const NOTIFY_INTERVAL_SECS: u64 = 24 * 60 * 60; | ||
| const FALLBACK_RELEASE_DATE: &str = "2026-04-17"; |
There was a problem hiding this comment.
For top-down style, these should be at the bottom of the module (current exceptions notwithstanding -- want to fix them up in a separate commit?).
| - `RUSTUP_NO_BACKTRACE`. Disables backtraces on non-panic errors even when | ||
| `RUST_BACKTRACE` is set. | ||
|
|
||
| - `RUSTUP_RELEASE_HINT` (default: `1`). When set to `0`, suppresses the hint |
There was a problem hiding this comment.
Do we have a strong reason to add this in addition to filesystem-based configuration? I am not a fan of the proliferation of environment variables that change rustup behavior.
There was a problem hiding this comment.
@djc I don't think #4869 (comment) is considered "configuration" because it just notes the last timestamp the routine is run...
| .map(|m| m.date.clone()) | ||
| .unwrap_or_else(|| FALLBACK_RELEASE_DATE.to_owned()); | ||
|
|
||
| let today = chrono::DateTime::from_timestamp(time_now as i64, 0) |
There was a problem hiding this comment.
Nit: suggest ditching the chrono:: prefixes everywhere.
| let release_date_str = distributable | ||
| .get_manifestation() | ||
| .and_then(|m| m.load_manifest()) | ||
| .ok() | ||
| .flatten() | ||
| .map(|m| m.date.clone()) | ||
| .unwrap_or_else(|| FALLBACK_RELEASE_DATE.to_owned()); |
There was a problem hiding this comment.
IMO this combinator-heavy style makes it pretty hard to understand what's actually going on. Suggest using more actual matches (and avoid flatten() in particular).
| - `RUSTUP_NO_BACKTRACE`. Disables backtraces on non-panic errors even when | ||
| `RUST_BACKTRACE` is set. | ||
|
|
||
| - `RUSTUP_RELEASE_HINT` (default: `1`). When set to `0`, suppresses the hint |
There was a problem hiding this comment.
Nit: I think it's a bit weird to start this with the negative case: cf. the documentation for RUSTUP_AUTO_INSTALL right below.
Closes #4846.
After a rustup command completes (excluding proxy commands), rustup checks whether a new Rust release is available.
To avoid introducing any additional overhead, this feature does not communicate with the release server.
Instead, it checks whether the stable toolchain manifest date is more than six weeks old.
Since Rust follows a regular and predictable release cadence, this should provide a sufficiently accurate indication that a new release is available.
When an outdated stable toolchain is detected, rustup prints a hint suggesting that the user may update their stable toolchain; this hint is shown at most once per day.
Users who prefer not to receive these hints can opt out by setting the
RUSTUP_NO_RELEASE_HINTenvironment variable.I have run some benchmarks (100 iterations) for the
rustup showcommand and observed no significant slowdown (1.1x) when we do not show the hint.However, due to manifest parsing, there is a 1.4x slowdown when the hint is shown (once per day).
Feedback is appreciated on: