The refactor in 6e8f5d0958247e4b4d629866099ed2836a0e0863 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>'
```
In #7526 a comparison for `paths` was introduced, but if `paths` is ever
`nil`, this triggers an error.
Coercing the variable to an Array should alleviate this problem, as
`nil.to_a` produces an empty and comparable Array.
Fixes#7540
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
We don't remove `etc` files on uninstall. Now we have `pkgetc`, though,
we have a pretty decent guess at what files in `etc` may belong to a
given package and can warn about them being left around on uninstall.
Thoughts: should we do the same thing for `var`? I don't see it being
used nearly as consistently.
If `Homebrew.args` hasn't yet been populated then `named` will return
`nil`. Instead, ensure it is an array before we try to `join` it.
This is pretty much only a test-time problem but has been causing flaky
builds.
Previously, this only included a subset of all the kegs the user was
trying to uninstall. With this change, all named formulae/kegs will be
included in the example command.