14

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?

6
  • 1
    You don't need to reformat. Just delete the Homebrew directory
    – mmmmmm
    Commented Jun 24, 2021 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. Commented Jun 24, 2021 at 16:59
  • @mmmmmm yes, I'm aware, I could probably also just uninstall/reinstall my packages, but I also love a clean slate ;-) Commented Jun 25, 2021 at 1:36
  • @MarcWilson good call on the dry run ! I knew about it, but I would have never tought about it ! Commented Jun 25, 2021 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. Commented Jun 25, 2021 at 8:20

3 Answers 3

11

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.

1
  • I swear to god, the yellow in bown is doing something to my eyes, I can't believe I looked over that part ! Commented Jun 25, 2021 at 1:34
11

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

$ brew deps --tree --include-build youtube-dl
youtube-dl
└── [email protected]
    ├── pkg-config
    ├── gdbm
    ├── mpdecimal
    ├── [email protected]
    ├── readline
    ├── sqlite
    │   └── readline
    └── xz

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

1
  • Thank you for the command to see dependencies, it'll be useful ! Commented Jun 25, 2021 at 1:37
2

Most likely because brew automatically upgraded other packages that use the dependencies of youtube-dl that were upgraded.

You can disable that behavior by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK:

export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1

You can show which packages depend on a specific package (these are called dependents):

brew uses --recursive --installed python

You must log in to answer this question.

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