rustup check: add exit status and no-self-update logic#4340
Merged
rami3l merged 2 commits intorust-lang:masterfrom May 23, 2025
Merged
rustup check: add exit status and no-self-update logic#4340rami3l merged 2 commits intorust-lang:masterfrom
rami3l merged 2 commits intorust-lang:masterfrom
Conversation
Contributor
Author
|
^ This push fixes the relevant tests to expect the new behavior/output. (I wasn't able to run tests earlier, but found that it was just flaky network tests and I could rerun them a few times.) |
rami3l
approved these changes
May 21, 2025
The 'self update' subcommand checks whether self updates have been disabled, but 'check' did not, meaning the check output could include updates you're powerless to accept. This adds the logic from self update to check, no longer showing updates that can't be applied by rustup, along with its --no-self-update flag, in case you *are* able to update rustup but don't want to check it for updates at the moment.
Contributor
Author
|
^ This push attempts to address the requests above by flattening CheckOpts and rebasing onto master to use the new testing APIs. |
rami3l
reviewed
May 22, 2025
This helps with interfaces above rustup, for example prompting a user to update, but only if updates are actually available. If any updates are available, exits 0, otherwise exits 1. This allows "natural" shell commands like 'if rustup check; then <update>'. It also mirrors existing exit codes for update, where rustup exits 1 if updates are not permitted by the distribution or because of errors.
Contributor
Author
|
^ This push updates to use |
This was referenced Jul 8, 2025
Merged
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.
First:
Then:
My use case is as described in the second commit: building a little interface on top of rustup to help a user stay updated, but not prompting them if there's not actually an update available. It was fairly easy to add an exit code to
rustup checkto represent what it found about available updates.I'm using a distribution-managed rustup, so seeing rustup updates in this process isn't actually useful; I see they're available but can't
rustup self updateto take care of them. I thought it made sense to use the same logic as inrustup self updateto determine whether to show self updates incheck. And sinceself updatehas an argument to force hiding that output (even if you can update) I did the same incheck.One potential downside here is the change in behavior of the exit status of
check, which is currently 0 regardless of available updates, unless rustup had an error. I believe this to be minor, given that an exit of 1 in existing code didn't really give an option for automated recovery, which matches the "nothing to do" result of 1 for not having available updates with this change. But I'd understand feedback about wanting a different exit code, or requiring a new flag to activate use of these exit codes.Another potential downside is the removal of some output of
checkin the no-self-update case. I see this as minor for a similar reason; there was nothing you could ask rustup to do with that output. If someone is using it to automate checks for rustup updates without actually using rustup for updating itself (?) it seems there are better ways.To test, I found that I could force an available toolchain update by removing its manifest file, and force a rustup update by lowering its version in Cargo.toml and reinstalling it to the test prefix. So, I tested each combination - no updates, toolchain update, rustup update, and toolchain + rustup update. I also tested with the no-self-update feature to confirm rustup updates are no longer shown, if desired.