Treat a `brew install` command as normal i.e. link by default unless
keg-only and only specify whether a keg should be linked when upgrading
or reinstalling. Also, adjust the naming accordingly so it's more
obvious that this is the case.
This means if a user has manually `brew unlink` or `brew link --force`d
something then that status will be preserved after they `brew upgrade`
or `brew reinstall` that formula.
This generally should make things that are keg-only by default easier
to swallow.
Only check runtime dependencies for version conflicts to avoid
having to create unnecessary duplicate formulae.
For example, a formula that needs to be built with ghc@8.0 should still
be allowed to have a build-time dependency on a cabal-install that was
itself built with ghc@8.2.
Improve the messaging around `brew install` when there's a possible user
action such as an `upgrade` or `link` and don't tell people to
`install --force` when it's unnecessary.
While I did this, tweak the output and function usage in a couple of
related places.
Some example output before this change:
```
Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
Warning: mysql@5.6 is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
Warning: analog-6.0_1 already installed
Warning: bash-completion@2-2.5 already installed, it's just not linked.
```
Some example output after this change:
```
Error: openssl 1.0.2k is already installed
To upgrade to 1.0.2l, run `brew upgrade openssl`
Warning: mysql@5.6 5.6.36_1 is already installed
Warning: analog 6.0_1 is already installed
Warning: bash-completion@2 2.5 is already installed, it's just not linked.
You can use `brew link bash-completion@2` to link this version.
```
Also, don't delete them after that. This means that `brew postinstall`
becomes a way to easily reinstall configuration files for any formula
without needing any changes to any bottles or requiring a reinstall.
If you `brew install` a formula that's already installed you get:
Warning: ripgrep-0.5.1 already installed
If you `brew install` an outdated formula that's installed you get:
Error: ripgrep-0.5.1 already installed. To install this version, first
`brew unlink ripgrep`
Instead, suggest that the user should `brew upgrade` in this case. If
the formula isn't outdated use the previous message.
We've been testing the recursive dependency check and allowing unlinked
dependencies in CI for a while with no adverse consequences so enable
them globally now for all users.
Rather than just checking if a requirement's dependency is installed or
not check if the requirement was actually satisfied by a particular
formula rather than e.g. just having a `default_formula` defined.
We can enable this locally and/or in `brew test-bot` to see if this
code is needed any more. If we can remove it we can start doing much
more interesting things with linking keg-only, versioned formulae and
system dupe formulae.
Also, report formulae installed on request. This is useful in
differentiating between those formulae that are popular because they
are widely requested and those that are popular because they are widely
depended on.
Return `opt_prefix` if it exists and `prefix` is not called from within
the same formula's `install` or `post_install` methods. Otherwise, fall
back to the existing functionality.
This avoids the need to use `opt_prefix` etc. everywhere and generally
means we don't expose an implementation detail (i.e. the full Cellar
path) to dependents that have a habit of hard-coding it.
Require `HOMEBREW_CHECK_RECURSIVE_VERSION_DEPENDENCIES` to be specified
(which will be by `brew test-bot`) to avoid this being inflicted on
end-users unnecessarily.
This is no longer needed as the reason it was added (argument
sanitisation) is now done properly.
Also, remove `skip_deps_check?` in favour of `ignore_deps?` as it too is
no longer needed.
- formula_installer: only recompute dependencies when necessary i.e.
when a bottle pour fails.
- formula_installer: re-add accidentally remove dependency options
- dependency: missing options are only those that actually exist on a
formula
When reading a building a formula from a keg (rather than e.g. from
name) then the deprecation options were not remapped correctly as they
are only done in `Tab.for_formula` and not `Tab.for_keg`. Ensure that
after we’ve created the formula that the `used_options` are remapped
correctly.