0

When compiling Homebrew packages from formulae, I wish to override a dependency, permanently and forever, for all existing packages/formulas, now and in the future.

I'm looking for a simple switch/setting/option/environment variable that I can change to accomplish that.

--ignore-dependencies doesn't work (at least under Homebrew 4.5.2-98).

Why do I need this?

I've got macOS Big Sur installed (the last OS by Apple that supports my beautiful Nvidia card) on Intel, so I have no option but to compile all packages manually — bottles won't work.

Homebrew is unable to compile cmake from the formula (no matter what). However, Homebrew also provides a cmake cask (which includes a nice GUI), which works flawlessly, without any dependency issues.

But all formulas simply ignore the cask. They will always attempt to install the formula, no matter what. And that makes them fail. Things are getting so out of hand that now most C++ compilations fail (llvm_clang seems to be broken; it requires cmake to be rebuilt; GCC is unable to compile everything, and, even when successful, it fails on the linking): the linker is unable to find the std library, and, without that, you simply can't link anything (C compilations are mostly unaffected).

A first step towards a solution would be to get all formulas to ignore the formula-based cmake and use the cask version instead — and start by reinstalling llvm from scratch, and moving upwards until all the 250+ broken formulae are fixed...

Did I check for suggestions elsewhere?

Sure. My first search was in the Homebrew manuals, which gives the 'dangerous' flag --ignore-dependencies as a workaround. Unfortunately, it seems that cmake is "special" in the sense that it cannot be overridden.

I have also manually edited *.rb formulae to simply not list cmake as a dependency. Again, that works — until an upgrade comes along. And, of course, this works only for formulae that have a single dependency, e.g. cmake. Others will need to manually change the *.rb files as well — until all dependencies are satisfied!

However, in most cases, the llvm linker (ld64) is still unable to find a compiled version of the C++ std library, and this means that even 'hacking' the *.rb files is just a temporary measure.

Here on Ask Different, I found a decade-old question similar to mine (How can I prevent Homebrew from installing a duplicate of software I installed through other means?). In their case, however, the culprit was not something so essential as cmake, and they found simple workarounds.

Another approach is also listed here: Why is brew trying to install a dependency that is already installed?

Again, these are very helpful suggestions, but, sadly, they didn't work for me.

In my case, I'm stuck with Homebrew's "virtual environment", so to speak, and cmake (or llvm...) are "outside" the usual formulae that can be overridden. I need a method that addresses this issue in perpetuity: in the recent past, cmake was a nightmare to compile manually so that Homebrew was happy with it, but I always succeeded, until 4.0 at least. But now it becomes too tough to fix — the weird "disappearance" of std breaks everything. On the other hand, obviously, llvm requires cmake to be compiled... so it's a circular dependency!

But isn't this just a llvm issue — not a Homebrew issue?

Maybe.

For all purposes, for llvm to be able to compile anything in C++, it must link with the standard library — which is used practically by all formulae, of course. I cannot explain why it is broken; although I do suspect that llvm is, for some stupid reason, attempting to use the GCC std library — which obviously won't work, of course. I fully admit that the co-existence of multiple compiler chains done by Homebrew is a big mystery to me. Nevertheless, it worked quite well for several years now. Until, well, something broke at the linking stage. The errors come from missing symbols in the std library. These errors should not exist at all. I can't even tell where llvm_clang or GCC are looking for their respective standard C++ library: the compiler chain, since it also has to take into account Xcode/stand-alone compiling tools, and the whole bunch of macOS frameworks and libraries and whatnot, is exceptionally confusing to me.

3
  • 1
    Pointing out that casks aren't software provided by Homebrew, no matter what they would like you to think. So given that there is a way to build cmake such that it runs, ask the actual developer who created it. Commented May 18 at 14:53
  • @MarcWilson that's actually a very good idea! Commented May 25 at 0:49
  • @MarcWilson in any case, I gave up. Bye-bye Homebrew forever. Hi again MacPorts, I missed you! Commented May 31 at 16:07

1 Answer 1

1

The short answer for this (even if doesn't solve your Homebrew problems) is that Homebrew doesn't support macOS Big Sur (macOS 11) any longer. From the Homebrew installation page

macOS 13 (Ventura) or higher is best and supported, 10.11 (El Capitan) – 12 (Monterey) are unsupported but may work and 10.10 (Yosemite) and older will not run Homebrew at all.

This means that the problems you are running into in keeping your Homebrew setup up and running will keep growing over time, even if you may find solutions for them now and then.

Assuming you don't want to rebuild everything from source yourself, MacPorts is a valuable alternative which also supports older versions of macOS.

6
  • sigh I suppose you're right. Now I just need to see how many of the 700 packages (well, packages and casks...) MacPorts still has. Oh well. Commented May 25 at 0:51
  • 1
    All right, your response is accepted. I gave up and installed MacPorts. I believe I will be able to survive with about 99% of the functionality — and only three out of all the 1515 ports installed so far required to be compiled from source. Now that is impressive! I never thought it would be that easy. I just need to figure out how to prevent Xquartz from starting automatically (and failing)!... Commented May 25 at 17:40
  • Do you actually need Xquartz for something? Commented May 26 at 4:39
  • 1
    @MarcWilson very, very rarely 😅 In any case, after making sure that I managed to clean up all possible files where launchd might try to launch Xquartz, it stopped. It wasn't easy, though — almost as persistent as Adobe, trying to launch all sorts of things in the background, and even deliberately hiding some of it using randomly-generated launchd .plists to confuse us further... Commented May 31 at 16:05
  • Why'd you install it, if you don't need it? If you installed a MacPorts port that required it, see if there's a variant that doesn't need it. Commented May 31 at 17:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.