Can't run "brew upgrade" due to "Undefined method 'uses_from_macos'" errors

I went on vacation for a few weeks and hadn’t run brew update in more than a month. When I came back and ran brew update && brew upgrade, the python formula failed to upgrade with the subject line’s error:

==> Upgrading python
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.4.mojave.bottle.tar.gz
######################################################################## 100.0%
...
==> Summary
🍺  /usr/local/Cellar/python/3.7.4: 3,865 files, 60MB
Removing: /usr/local/Cellar/python/3.7.3... (3,909 files, 60.6MB)
Error: glib: undefined method `uses_from_macos' for Formulary::FormulaNamespace1b33d7b036781a8c4dc38a980a07e0d5::Glib:Class

I uninstalled python and other packages that depended on it, ran brew upgrade again, and another formula (libidn2) failed:

==> Upgrading libidn2
==> Downloading https://homebrew.bintray.com/bottles/libidn2-2.2.0_1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libidn2-2.2.0_1.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/libidn2/2.2.0_1: 70 files, 700.9KB
Removing: /usr/local/Cellar/libidn2/2.1.1a... (69 files, 691.8KB)
Error: cabal-install: undefined method `uses_from_macos' for #<Class:0x00007fd68a0ad490>

My brew was outdated (2.0.6, expected 2.1.x after running brew update prior to upgrading). Re-running brew update reported Already up-to-date, and brew doctor didn’t flag anything:

$ brew --version
Homebrew 2.0.6-56-gc59c03e
Homebrew/homebrew-core (git revision 276f2; last commit 2019-07-10)
Homebrew/homebrew-cask (git revision c781b; last commit 2019-07-11)

$ brew update
Already up-to-date.

A workaround was to re-run the installation script:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew...
HEAD is now at 74920d966 Merge pull request #6290 from lembacon/bottle_publisher-bottle_info
Already up-to-date.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation:
    https://docs.brew.sh

$ brew --version
Homebrew 2.1.7-12-g74920d9
Homebrew/homebrew-core (git revision 276f2; last commit 2019-07-10)
Homebrew/homebrew-cask (git revision c781b; last commit 2019-07-11)

after which brew upgrade ran without issue and re-installed the python and glib formulas.

I was under the impression that re-running the installation script should not be necessary, and brew update should keep brew itself up-to-date.

  1. What is the expected behavior of running brew update when brew itself is outdated?
  2. Is re-running the installation script the correct solution? If so, can that be added to the documentation?

I did review Undefined method `uses_from_macos` before posting this, which reports the same error but was apparently the result of an unsupported scenario involving Julia (which apparently uses its own vendored brew).

This is not related to Julia and involved pretty standard formulas, like python.

Brew update should update the tool, upgrade does the software you installed.
While running the install script would fix it, this only happens if you mess with the git setup of brew itself. Next time brew update-reset might save you some time.

1 Like