rustup check: add exit status and no-self-update logic #4340
+80
−13
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 check
to 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 update
to take care of them. I thought it made sense to use the same logic as inrustup self update
to determine whether to show self updates incheck
. And sinceself update
has 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
check
in 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.