formula_installer: Fix --only-dependencies formula arch handling

- For a formula with an architecture requirement and a user requesting
  `--only-dependencices` to be installed, this now proceeds to install the
  formula dependencies regardless of the requested formula architecture because
  the formula itself will never be installed.
- The way dependencies and requirements are computed, the `depends_on :arch` is
  still a dependency, so it's in the list of formula dependencies to check and
  potentially install. Hence, we have to remove from the list the dependent
  from `recursive_requirements` with the same name as the formula so that there
  are no confusing unsatisfied requirements for the named formula when we don't
  need it to be installed.
- I thought about why this might be, maybe it's because we can't guarantee that
  formula dependencies work on different architectures. But in that case they'd
  have their own architecture requirements, so we'd see the failure for them.
  So I don't know of any more reasons.

Before:

```shell
$ brew install --only-dependencies julia
julia: The x86_64 architecture is required for this software.
Error: julia: An unsatisfied requirement failed this build.
```

After:

```shell
❯ brew install --only-dependencies julia
==> Downloading [...]
==> Installing dependencies for julia: libnghttp2, mpfr and suite-sparse
```
This commit is contained in:
Issy Long 2022-03-06 21:21:21 +00:00
parent 67512aed56
commit 8b7a9a2430
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -579,7 +579,8 @@ class FormulaInstaller
if req.prune_from_option?(build) ||
req.satisfied?(env: @env, cc: @cc, build_bottle: @build_bottle, bottle_arch: @bottle_arch) ||
((req.build? || req.test?) && !keep_build_test) ||
formula_deps_map[dependent.name]&.build?
formula_deps_map[dependent.name]&.build? ||
(only_deps? && f == dependent)
Requirement.prune
else
unsatisfied_reqs[dependent] << req