Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine suggestions about missing components #3453

Merged
merged 6 commits into from
Oct 26, 2023

Conversation

rami3l
Copy link
Member

@rami3l rami3l commented Aug 18, 2023

Closes #3418. I also cleaned up the current code a bit along the way.

cc #2355

@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from b9d70eb to e152dc7 Compare August 20, 2023 05:48
src/errors.rs Show resolved Hide resolved
src/errors.rs Show resolved Hide resolved
@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from 2d83297 to d4ae176 Compare August 20, 2023 11:16
@rami3l
Copy link
Member Author

rami3l commented Aug 20, 2023

@rbtcollins Looking at the blackbox test suite, it seems to me that this fix is more than what it seems to be.

In toolchain updates, component_unavailable_msg

fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &str) -> String {

does get called, but the generated error then gets caught and re-thrown

rustup/src/dist/dist.rs

Lines 938 to 946 in a4dd7d0

Some(RustupError::RequestedComponentsUnavailable {
components,
manifest,
toolchain,
}) => Err(anyhow!(DistError::ToolchainComponentsMissing(
components.to_owned(),
Box::new(manifest.to_owned()),
toolchain.to_owned(),
))),

to components_missing_msg

fn components_missing_msg(cs: &[Component], manifest: &ManifestV2, toolchain: &str) -> String {

, which instead suggests using a minimal profile, so the original suggestion in the former (uninstall the component in question) might not be applicable at all anymore, as the error message from the former can only be seen in some edge cases (like adding miri to stable, but not upgrading to a new nightly which lacks rls).

To move this fix forward, I could simply remove the suggestion in component_unavailable_msg, however, I want to know more about the semantic differences between these two functions in order to make the final decision.

For example, since this help message is very well-written, I wish to be able to see it in toolchain updates as well:

rustup/src/errors.rs

Lines 22 to 28 in a4dd7d0

const TOOLSTATE_MSG: &str =
"If you require these components, please install and use the latest successful build version,\n\
which you can find at <https://rust-lang.github.io/rustup-components-history>.\n\nAfter determining \
the correct date, install it with a command such as:\n\n \
rustup toolchain install nightly-2018-12-27\n\n\
Then you can use the toolchain with commands such as:\n\n \
cargo +nightly-2018-12-27 build";

rami3l added a commit to rami3l/rustup that referenced this pull request Aug 21, 2023
…_unavailable_msg`

After digging into the codebase, I realized that the message generated
by `component_unavailable_msg` is used only when:

- Some components are missing from the toolchain so that the
  installation can no longer proceed;
- We are not installing these components as a part of a
  toolchain-wide operation (e.g. updating the existing `nightly`),
  which is covered by `components_missing_msg` by catching the
  `RustupError::RequestedComponentsUnavailable` and re-throwing
  it as a `DistError::ToolchainComponentsMissing`
  (see <rust-lang#3453 (comment)>
  for more info).

Thus, I decided to remove the `rustup component remove` suggestion
altogether.
@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from d4ae176 to a3df139 Compare August 21, 2023 03:23
@rami3l rami3l marked this pull request as draft August 21, 2023 03:35
@rami3l
Copy link
Member Author

rami3l commented Aug 21, 2023

Note: dist::manifestation::tests::unavailable_component and friends test rustup::dist::manifestation::Manifestation::update directly (by checking the very rustup component remove suggestion), which happens before the catch-rethrow dance in rustup::dist::dist::try_update_from_dist_, so these tests are expected to fail at the moment.

... and they are not accurate anyway since the string form of those errors (before the catch-rethrow dance) is NOT ALWAYS visible to end users, which might cause further confusions for maintainers later on.

@rami3l
Copy link
Member Author

rami3l commented Aug 21, 2023

I've yet to see any use case or test case that disobeys the observation stated in 6b5cb9f 's commit message.

Therefore, I think by now it is reasonable to do the following:

  • Add a new blackbox test case to ensure that Confusing component add error message #3418 does get fixed.
  • Move TOOLSTATE_MSG to dist to serve toolchain-wide operations (since it also talks about toolchain changes) by appending it to the end of component_missing_msg's output.

@rami3l rami3l marked this pull request as ready for review August 22, 2023 12:36
rami3l added a commit to rami3l/rustup that referenced this pull request Aug 24, 2023
…_unavailable_msg`

After digging into the codebase, I realized that the message generated
by `component_unavailable_msg` is used only when:

- Some components are missing from the toolchain so that the
  installation can no longer proceed;
- We are not installing these components as a part of a
  toolchain-wide operation (e.g. updating the existing `nightly`),
  which is covered by `components_missing_msg` by catching the
  `RustupError::RequestedComponentsUnavailable` and re-throwing
  it as a `DistError::ToolchainComponentsMissing`
  (see <rust-lang#3453 (comment)>
  for more info).

Thus, I decided to remove the `rustup component remove` suggestion
altogether.
@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from 03456ff to 3cc2f55 Compare August 24, 2023 03:52
rami3l added a commit to rami3l/rustup that referenced this pull request Aug 25, 2023
…_unavailable_msg`

After digging into the codebase, I realized that the message generated
by `component_unavailable_msg` is used only when:

- Some components are missing from the toolchain so that the
  installation can no longer proceed;
- We are not installing these components as a part of a
  toolchain-wide operation (e.g. updating the existing `nightly`),
  which is covered by `components_missing_msg` by catching the
  `RustupError::RequestedComponentsUnavailable` and re-throwing
  it as a `DistError::ToolchainComponentsMissing`
  (see <rust-lang#3453 (comment)>
  for more info).

Thus, I decided to remove the `rustup component remove` suggestion
altogether.
@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from 3cc2f55 to 6f61089 Compare August 25, 2023 10:41
@rbtcollins
Copy link
Contributor

I've yet to see any use case or test case that disobeys the observation stated in 6b5cb9f 's commit message.

Therefore, I think by now it is reasonable to do the following:

* [x]  Add a new blackbox test case to ensure that [Confusing `component add` error message #3418](https://github.com/rust-lang/rustup/issues/3418) does get fixed.

* [x]  Move `TOOLSTATE_MSG` to `dist` to serve toolchain-wide operations (since it also talks about toolchain changes) by appending it to the end of `component_missing_msg`'s output.

seems reasonable to me

@rami3l
Copy link
Member Author

rami3l commented Aug 31, 2023

I've yet to see any use case or test case that disobeys the observation stated in 6b5cb9f 's commit message.
Therefore, I think by now it is reasonable to do the following:

* [x]  Add a new blackbox test case to ensure that [Confusing `component add` error message #3418](https://github.com/rust-lang/rustup/issues/3418) does get fixed.

* [x]  Move `TOOLSTATE_MSG` to `dist` to serve toolchain-wide operations (since it also talks about toolchain changes) by appending it to the end of `component_missing_msg`'s output.

seems reasonable to me

@rbtcollins ... and those two tasks have been done, together with a new black box test case for the latter.
Would you mind reviewing my changes?

@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from 6f61089 to bcab5b8 Compare October 5, 2023 09:17
@rami3l rami3l requested a review from rbtcollins October 5, 2023 12:23
@rami3l rami3l mentioned this pull request Oct 5, 2023
rami3l added a commit to rami3l/rustup that referenced this pull request Oct 8, 2023
…_unavailable_msg`

After digging into the codebase, I realized that the message generated
by `component_unavailable_msg` is used only when:

- Some components are missing from the toolchain so that the
  installation can no longer proceed;
- We are not installing these components as a part of a
  toolchain-wide operation (e.g. updating the existing `nightly`),
  which is covered by `components_missing_msg` by catching the
  `RustupError::RequestedComponentsUnavailable` and re-throwing
  it as a `DistError::ToolchainComponentsMissing`
  (see <rust-lang#3453 (comment)>
  for more info).

Thus, I decided to remove the `rustup component remove` suggestion
altogether.
@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from 7798b4a to 3a0950b Compare October 8, 2023 11:27
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep unrelated changes in separate commits, makes it much easier to review.

src/dist/dist.rs Show resolved Hide resolved
src/dist/dist.rs Outdated Show resolved Hide resolved
…_unavailable_msg`

After digging into the codebase, I realized that the message generated
by `component_unavailable_msg` is used only when:

- Some components are missing from the toolchain so that the
  installation can no longer proceed;
- We are not installing these components as a part of a
  toolchain-wide operation (e.g. updating the existing `nightly`),
  which is covered by `components_missing_msg` by catching the
  `RustupError::RequestedComponentsUnavailable` and re-throwing
  it as a `DistError::ToolchainComponentsMissing`
  (see <rust-lang#3453 (comment)>
  for more info).

Thus, I decided to remove the `rustup component remove` suggestion
altogether.
@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from 3a0950b to 512a2cd Compare October 10, 2023 09:23
@rami3l rami3l force-pushed the fix/better-missing-component-suggestions branch from 512a2cd to aee34d9 Compare October 10, 2023 10:10
@rami3l rami3l requested a review from djc October 10, 2023 10:14
@rami3l rami3l self-assigned this Oct 22, 2023
@djc djc merged commit b5d74ac into rust-lang:master Oct 26, 2023
16 checks passed
djc pushed a commit that referenced this pull request Oct 26, 2023
…_unavailable_msg`

After digging into the codebase, I realized that the message generated
by `component_unavailable_msg` is used only when:

- Some components are missing from the toolchain so that the
  installation can no longer proceed;
- We are not installing these components as a part of a
  toolchain-wide operation (e.g. updating the existing `nightly`),
  which is covered by `components_missing_msg` by catching the
  `RustupError::RequestedComponentsUnavailable` and re-throwing
  it as a `DistError::ToolchainComponentsMissing`
  (see <#3453 (comment)>
  for more info).

Thus, I decided to remove the `rustup component remove` suggestion
altogether.
@rami3l rami3l deleted the fix/better-missing-component-suggestions branch October 26, 2023 12:52
@rami3l rami3l added this to the 1.27.0 milestone Jan 18, 2024
@rami3l rami3l mentioned this pull request Jan 29, 2024
1 task
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.

Confusing component add error message
3 participants