Skip to content

Fix printing MultipleVersionsInstalledError details #8670

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

Merged

Conversation

mistydemeo
Copy link
Contributor

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

The refactor in 6e8f5d0 means that the exception no longer exposes the name of the package with multiple versions, and as a result the rescuer is unable to print this information.

Because we now have a path in which MultipleVersionsInstalledError doesn't have the name at all, we can't reasonably restore the old behaviour. And since rack resolution happens purely internal to the function that raises the exception, the caller has no way to know what name to use. However, since the exception text gets printed anyway, we can just move this text into the exception itself.

Fixes the following error:

Error: mpd has multiple installed versions
Error: undefined method `name' for #<MultipleVersionsInstalledError:0x00007fc6009d8870>
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:137:in `rescue in uninstall'
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:135:in `uninstall'
/usr/local/Homebrew/Library/Homebrew/brew.rb:119:in `<main>'

New behaviour:

Error: mpd has multiple installed versions
Run `brew uninstall --force mpd` to remove all versions.

cc @whoiswillma

Sorry, something went wrong.

Copy link
Contributor

@whoiswillma whoiswillma left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for catching this!

The refactor in 6e8f5d0 means that the
exception no longer exposes the name of the package with multiple versions,
and as a result the rescuer is unable to print this information.

Because we now have a path in which MultipleVersionsInstalledError doesn't
have the name at all, we can't reasonably restore the old behaviour.
And since rack resolution happens purely internal to the function that
raises the exception, the caller has no way to know what name to use.
However, since the exception text gets printed anyway, we can just move
this text into the exception itself.

Fixes the following error:

```
Error: mpd has multiple installed versions
Error: undefined method `name' for #<MultipleVersionsInstalledError:0x00007fc6009d8870>
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:137:in `rescue in uninstall'
/usr/local/Homebrew/Library/Homebrew/cmd/uninstall.rb:135:in `uninstall'
/usr/local/Homebrew/Library/Homebrew/brew.rb:119:in `<main>'
```
@mistydemeo mistydemeo force-pushed the fix_multiple_version_messaging branch from 91a0873 to c06848c Compare September 9, 2020 18:57
@mistydemeo mistydemeo merged commit 6474e65 into Homebrew:master Sep 9, 2020
@mistydemeo mistydemeo deleted the fix_multiple_version_messaging branch September 9, 2020 19:30
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 13, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants