rust-lang / rust-lang/rustup

Tracking: Notify users of available toolchain updates

Open
#3,688 16 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

Problem you are trying to solve

It is not uncommon for Rust users to have old version of Rust installed without realizing it. This is problematic for users:

  • best-case they miss out on new features
  • or miss out on improvements to the type system or borrow checker
  • they may be using a toolchain with known bugs
  • or, worst-case, one with security vulnerabilities

It's especially important for users to be notified of "patch" releases which often roll out only when there is a severe issue with a "minor" release toolchain.

Solution you'd like

Essentially, regularly check for toolchain updates and notify users when they run a rustup command or when they run a cargo command through the rustup proxy.

Prompt on Rust install

On install, users should be asked if they want Rustup to periodically check for updates when invoking cargo and rustup commands:

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>

Rustup can periodically check for and download `stable` toolchain 
updates. These actions will only be started when `cargo` or 
`rustup` commands are invoked.

For more information, see https://rust-lang.github.io

1) Never check or download
2) Check monthly, but don't download
3) Check weekly, but don't download
4) Check daily, but don't download
5) Check monthly and download in the background
6) Check weekly and download in the background (default)
7) Check daily and download in the background
>
Notice when running command

When a rustup command is executed or any cargo command is executed via the Rustup proxy on the stable toolchain, begin checking for updates in a background process. Wait with a short timeout; if the check has not completed by then, display a message to the user on the next invocation. If the update check did complete in time, directly display a message to the user.

The message to display:

$ cargo check
Rustup notice: Update available for the `stable` toolchain.
    
    stable-x86_64-unknown-linux-gnu    1.74.0 -> 1.76.0

Update packages will be downloaded in the background.
Run `rustup update -N` to complete the update.

    Checking project v0.1.0 (/home/user/Dev/project)
    Finished dev [unoptimized + debuginfo] target(s) in 7.95s

Update packages will be downloaded in the background. would obviously not be shown if the user hadn't enabled downloading.

rustup update --notice

The -N flag (short for --notice) tells Rustup to only run the update that the user was informed of in the most recent notice. If the download was not started, then rustup update -N will run essentially the same as a rustup update stable does today: starting the downloads, wait for them to complete, then install them. If the download started but not completed, then rustup update -N will complete the download and install the update. If the download has already completed, then it will just install the downloaded update.

If a background-downloaded update was never installed and a newer version is detected, the older download will be deleted.

Notes

Timeout duration

We want something long enough to allow the update check to complete for most users, but imperceptible if the update check takes a long time. Something around 100ms-200ms.

Display notice after cargo command

We may want the Rustup notice to show after the cargo command runs so the notice doesn't get buried in the cargo output. However, we can't directly print the notice from rustup without changing the way the cargo proxies work. Instead, cargo could add a special command-line option or environment variable for an info item if prints out at the end. It could work something like this:

$ ~/.cargo/bin/cargo check
    CARGO_JSON_PASSTHROUGH = '{
        "reason": "info",
        "placement": "after_compile",
        "message": "Rustup notice: Update available for the `stable` toolchain ..."
    }'
    ~/.rustup/toolchains/stable-.../bin/cargo check

Of course, this would not be compatible with cargo run, so we'd need to do some amount of argument parsing. It could be very basic though, even just checking for run.

How often to display the notice

We don't want to spam the user with notices, otherwise they'll just learn to ignore them. A reasonable behavior might be:

  • Never display a notice while actively downloading in the background
  • Only display a notice at most once an hour
  • Take care to only display notices where users will actually see them
    • when executed directly by the user in a terminal
    • NOT when executed programmatically
    • (maybe) when cargo output is being passed to rust-analyzer or another external tool

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the rustup installation prompt, the rustup command and cargo proxy entry points, and existing update handling. Clarify the design for background checks, notice timing, direct-terminal output, and rustup update --notice; the work is done when these behaviors and the download and installation states are specified and implemented consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.