Skip to content

feat(cli): add --check flag to rustup update for semantic exit codes - #4992

Closed
gkamathe wants to merge 1 commit into
rust-lang:mainfrom
gkamathe:add-check-flag
Closed

feat(cli): add --check flag to rustup update for semantic exit codes#4992
gkamathe wants to merge 1 commit into
rust-lang:mainfrom
gkamathe:add-check-flag

Conversation

@gkamathe

@gkamathe gkamathe commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This adds a --check flag to rustup update that causes the command to set its exit code based on whether any toolchains were actually updated:

  • 0 — no updates were applied; everything was already up to date
  • 100 — at least one toolchain was updated
  • 1 — an error occurred

Without --check, the behavior is unchanged (exit 0 on success regardless of whether updates occurred). This preserves backward compatibility for existing workflows.

The exit codes align with rustup check (#4681).

Closes #4987

Changes

  • Added --check flag to the rustup update subcommand
  • Modified update() to track whether any toolchain's UpdateStatus was
    Installed or Updated, and return ExitCode::UPDATES_AVAILABLE (100)
    when --check is set and updates occurred
  • Modified update_all_channels() to return whether any channel was updated
    alongside the existing exit code
  • Added exit status documentation to update_help() in help.rs
  • Added 4 integration tests covering: no updates (exit 0), with updates
    (exit 100), without --check (always exit 0), and all-channels update

Test plan

  • cargo fmt --all --check passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo test --features=test passes
  • New tests update_check_no_updates, update_check_with_updates,
    update_without_check_always_succeeds, and update_check_all_channels
    all pass

When --check is passed, rustup update returns exit code 100 if any
of the requested toolchains were updated, and 0 if everything was
already up to date. Without --check, behavior is unchanged.

Closes rust-lang#4987
@rami3l

rami3l commented Aug 3, 2026

Copy link
Copy Markdown
Member

Hello!

I have reasons to believe that this PR is low-effort and has violated our contributing guidelines (LLM usage is explicitly banned for E-easy unless agreed otherwise):

If you are opening a pull request, you are expected to be able to explain the proposed changes in
your own words. This includes the pull request body and responses to questions. Make sure you have
reviewed the PR yourself before submitting it for review to the maintainers. Do not copy responses
from the AI when replying to questions from maintainers. As an exception, issues marked as `E-easy`
are meant for new contributors as a learning opportunity; the use of an LLM when submitting PR for
such issues is disallowed except without explicit permission from the team. Failure to comply may
result in the PR being closed directly without further notice.

As such, I'm closing it now.

@rami3l rami3l closed this Aug 3, 2026
@gkamathe
gkamathe deleted the add-check-flag branch August 3, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to indicate update via exit code

2 participants