This came up recently where an outdated formula definition
caused the program to crash with an ambiguous message when
a user wanted to upgrade a cask instead. Catching these errors
allows them to get handled later on improving error messages
and defaults. Now if the only formula with the given name is
invalid it will default to using the cask unless --formula is
specified.
- https://github.com/Homebrew/brew/issues/16123
Before this change, external commands, whether official or not, cannot
use the `env:` DSL for `Homebrew::CLI::Parser` without adding their
environment variable to `Homebrew::EnvConfig`.
Instead, if the method is not defined, check the environment variable
directly. This allows `env:` to be used as expected and allows
simplifying some (new) code in e.g. `brew bundle`.
- For the command `brew install --cask racket`, a user was reporting the
behaviour where despite `--cask` in the command, they were getting
output about the `racket` formula having been renamed:
```
$ brew install --cask racket
Warning: Use minimal-racket instead of deprecated racket
==> Downloading https://mirror.racket-lang.org/installers/8.7/racket-8.7-x86_64-macosx-cs.
==> Installing Cask racket
[...]
racket was successfully installed!
```
- The "instead of deprecated ..." messaging comes from the `TapLoader`
class `formula_name_path` method, so _something_ must be assuming
that everything is initially a formula before _later_ learning from
further args parsing that there's a `--cask` qualifier to scope to
only casks.
- There are always `@formula_options` and args parsing is recursive,
going through each option, so we check that the original `argv` items
include a `--cask` and skip calling the `formulae` method if that's
the case.
- After this change, the "formula renames" words no longer show up.
```
$ brew install --cask racket
==> Downloading https://mirror.racket-lang.org/installers/8.7/racket-8.7-aarch64-macosx-cs.dmg
==> Installing Cask racket
[...]
racket was successfully installed!
```
This ability was removed around a month
ago but needs to be added back in.
Developers want to be able to use the
`bump` and `audit` commands when on Linux.
This is especially useful for CI.
1. Validate options before constraint violations. This allows
us to error out when --cask is passed on Linux before getting
a constraint violation when --cask and --formula are set.
2. Skip printing the help page when --cask is passed on Linux.