Optional dependencies mean that it is possible to install the package without having the dependency installed. Normally Homebrew installs all dependencies automatically, but --ignore-dependencies is an option that disables this behaviour. But even with --ignore-dependencies, build.rb is desperate to have a working /opt prefix for every formula in the dependency tree and raises an exception if it cannot achieve this:
Error: /usr/local/opt/$dependency not present or broken
Please reinstall $dependency. Sorry :(
The attached patch simply prevents build.rb from trying to do anything whatsoever with dependencies that are not actually installed: thus we have no spurious errors, no superfluous components in paths and no unwarranted switching to stdenv.
build: ignore dependencies that are not installed
Among other things, this fixes "prefix/opt/formula not present
or broken. Please reinstall formula. Sorry :(" errors when some
optional dependencies are missing and `brew install` is run
with the `--ignore-dependencies` option.
See also: #14456
That looks awesome!
I believe it does solve this issue too, but how soon will it be merged? If that’s still a way off, this could be pulled in the meantime.
I haven't had much uninterrupted time to work on it lately but I still hope to finish and merge it "soonish". I'll take a closer look at this tomorrow, though.
Fixed in 3831d10 - or at least hacked to work again.
That does fix the error, but it also means that dependencies that are installed but haven’t yet got an opt-prefix will be missed. My solution isn’t much more complicated (even if I change several lines, effectively all changes are the same), so I don’t see why you don’t want to pull it instead. In fact, if the number of changes is the reason, you can cut it down to a single-line hack by only retaining the change in line 72.
Reopening for review.
@astiob @adamv @jacknagel With the new dependency code I think this is now redundant. If I'm wrong reopen. Sorry for not merging and thanks!