This just improves the messaging in the `#to_formulae_and_casks_with_taps`
method so that users have a better idea of what to try next.
Ex.
```
Error: These formulae and casks are not in any locally installed taps!
- discord
- iterm2
- visual-studio-code
- zstd
You may need to run `brew tap` to install additional taps.
```
There are two big changes here. Both have to do with how we want
to load casks in different scenarios. One also is related to formulae.
1. Prevent loading casks & formulae outside of taps for specific commands.
There are certain commands like `bump`, `bump-*-pr`, `livecheck` and `audit`
where it really makes no sense to try and run things if the specified formulae
or cask is not in a tap. A new `#to_formulae_and_casks_with_taps` method was
added to the `CLI::NamedArgs` class to allow us to easily grab and validate
formulae and casks from named arguments.
2. Always load the source file path when loading casks with the path loader.
There was an edge case where all JSON cask files were being loaded without
setting the source file path because most of the work was handed off to the
API loader where that normally would make more sense. Now we set that when
calling the API loader which solves the problem. This improves the user
experience of people using the `--cache` and `fetch` commands in certain
edge cases. Hopefully it makes the user experience a bit more consistent.
A regression test was added for this point.
This updates logic to add a `#scheme_and_version` method to be used
with `.sort_by` and `.max_by`. Using `Keg#version` by itself can be
inaccurate when different version schemes are present. This also
updates the behavior of `Formula#eligible_kegs_for_cleanup` to match
the previous behavior. We were dropping the wrong keg based on the
sort being reversed in a previous PR.
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 we used to evaluate all named arguments as local paths
first. This means that the following could be a name conflict.
$ brew edit src
If there was a local file or directory named src, it would default
to that. Otherwise it would search for a formula/cask with the
same name and return that.
Now it will only default to the local path if the named argument
starts or ends with a slash ('/') or includes a period ('.').
This means that in the event of a name clash with a normal package
name it will default to the package instead of the local file.
It also fixes an edge case where the following would be interpreted
as a tap name.
$ brew edit /src
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`.
- keep running the command against all os/arch combinations
as the default
- remove todos and deprecations related to changing the behavior
- create constants for os/arch combinations
- Load paths with no API when needed (e.g. for `brew edit`)
- Use no API mode for `brew log` as it's needed there
- Define sharding format for homebrew-cask and homebrew-core inside
`Tap` methods
- Create new formulae/casks in location defined by these `Tap` methods
- Fix a bug in Formulary that made sharded formulae lookup less
efficient (and possibly broke it for core and some API usage)
- Fix various other hardcoded Formula/Cask directory assumptions
Co-authored-by: Bo Anderson <mail@boanderson.me>