So I needed to upgrade youtube-dl, and ran brew upgrade youtube-dl. While it was running, homebrew decided it needed to upgrade a lot more stuff, including all of my installed PHP versions... And now, none of them works like they should anymore (error messages in cli, modules not loaded, etc.).

I'm going to go on and probably reformat my machine to have a clean slate, but I wonder why running brew upgrade while explicitely giving the package to upgrade would update others. I understand dependencies, but I highly doubt that youtube-dl is dependent on PHP 7.4 and PHP 8.0, and others.

Is there a flag I missed? Anything else?

  • You don't need to reformat. Just delete the Homebrew directory – mmmmmm Jun 24 at 14:28
  • No, but something youtube-dl is dependent on is likely dependent on something else which is dependent on something else. That's the idea of a dependency tree. I'm sure that homebrew has something that will show you the dependency tree, it can't be so broken that it does not. It also has --dry-run which should always be used before actually letting it do anything. – Marc Wilson Jun 24 at 16:59
  • @mmmmmm yes, I'm aware, I could probably also just uninstall/reinstall my packages, but I also love a clean slate ;-) – Jean-Philippe Murray Jun 25 at 1:36
  • @MarcWilson good call on the dry run ! I knew about it, but I would have never tought about it ! – Jean-Philippe Murray Jun 25 at 1:36
  • 1
    None of the existing answers explicitly addresses why updating formulae often breaks stuff. This is quite common with Python, for instance. As far as I'm aware the reason is mixing of installer systems (e.g. Homebrew & pip), and the fact that installed executables often hard-code paths to libraries and interpreters, which include the version string. It's an infuriating situation. Unfortunately there's no simple solution. – Konrad Rudolph Jun 25 at 8:20

Homebrew FAQ:

Why does brew upgrade also upgrade a bunch of other stuff?

Homebrew doesn’t support arbitrary mixing and matching of formula versions, so everything a formula depends on, and everything that depends on it in turn, needs to be upgraded to the latest version as that’s the only combination of formulae we test. As a consequence any given upgrade or install command can upgrade many other (seemingly unrelated) formulae, if something important like python or openssl also needed an upgrade.

How do I stop certain formulae from being updated?

To stop something from being updated/upgraded:

brew pin <formula>

To allow that formulae to update again:

brew unpin <formula>

Note that pinned, outdated formulae that another formula depends on need to be upgraded when required, as we do not allow formulae to be built against outdated versions. If this is not desired, you can instead brew extract to maintain your own copy of the formula in a tap.

  • I swear to god, the yellow in bown is doing something to my eyes, I can't believe I looked over that part ! – Jean-Philippe Murray Jun 25 at 1:34

To see the dependency tree of a Homebrew package, use brew deps --tree <package>:

$ brew deps --tree --include-build youtube-dl
└── python@3.9
    ├── pkg-config
    ├── gdbm
    ├── mpdecimal
    ├── openssl@1.1
    ├── readline
    ├── sqlite
    │   └── readline
    └── xz

youtube-dl, php and php@7.4 all depend on python@3.9. I could imagine that updating youtube-dl triggered an update of python@3.9 which was incompatible with the installed versions of php/php@7.4, therefore triggering an update of those packages as well.

  • Thank you for the command to see dependencies, it'll be useful ! – Jean-Philippe Murray Jun 25 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .