Error: uninitialized constant Cask::CaskLoader::FromURILoader::Cache

Hello folks,

I maintain a python app that we use at my work, and we distribute it for MacOS via brew. Since many of my users don’t have access to our internal github to be able to tap the formula, we simply have them install the bottle direcly from an https url, so installation looks like:
brew install https://internal.site/package-20.8.3.high_sierra.bottle.tar.gz
and for existing users, upgrading looks like:
brew upgrade --force-bottle https://internal.site/package-20.8.3.high_sierra.bottle.tar.gz
And we’ve been doing it this way since July of last year without issues.

Just recently (my first report is from September 8th), users have started reporting that they’re unable to upgrade. I am able to reproduce this on my own machine. If I install the second-most-recent version and then try to upgrade to the most recent, here’s what I get:

~ → brew upgrade --force-bottle https://internal.site/package-20.8.3.high_sierra.bottle.tar.gz
Updating Homebrew...
==> Downloading https://internal.site/package-20.8.3.high_sierra.bottle.tar.gz
Already downloaded: /Users/me/Library/Caches/Homebrew/downloads/0f81b408d98698220284350f3864ad0bdf78c3bb07b5222207a73d300af3cceb--package-20.8.3.high_sierra.bottle.tar.gz
==> Pouring the cached bottle
==> Downloading https://internal.site/package-20.8.3.high_sierra.bottle.tar.gz
Already downloaded: /Users/me/Library/Caches/Homebrew/downloads/0f81b408d98698220284350f3864ad0bdf78c3bb07b5222207a73d300af3cceb--package-20.8.3.high_sierra.bottle.tar.gz
==> Pouring the cached bottle
Error: uninitialized constant Cask::CaskLoader::FromURILoader::Cache
Please report this issue:
  https://docs.brew.sh/Troubleshooting
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:101:in `initialize'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:206:in `new'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:206:in `block in for'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:205:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:205:in `for'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:194:in `load'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:210:in `warn_if_cask_conflicts'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:63:in `block in to_resolved_formulae_to_casks'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:60:in `each'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:60:in `to_resolved_formulae_to_casks'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:76:in `upgrade'
/usr/local/Homebrew/Library/Homebrew/brew.rb:119:in `<main>'
 ~ → echo $?                                                                                                                                               ⍉
1

Perhaps there was some breaking change to the way bottles are handled in homebrew, or perhaps there’s some update needed to my formula?

If I have people uninstall the current version and then install the new version, it works without issue. It’s only upgrading that triggers this.

Can you post brew config and brew doctor, and steps to reproduce using a public URL? If it works with a Homebrew-provided bottle that would be ideal (e.g. from brew fetch wget or something like that).

Actually, I figured it out. Can you file an issue at Homebrew/brew? Thanks!

Bisecting: 0 revisions left to test after this (roughly 0 steps)
[e3372e2a14dde3adab0423379a9de9b72a47d616] Lazily require some heavy files
running brew upgrade https://homebrew.bintray.com/bottles/wget-1.20.3_2.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/wget-1.20.3_2.catalina.bottle.tar.gz
Already downloaded: /Users/jonchang/Library/Caches/Homebrew/downloads/a160b20d674052d2077aa12a47eb037cbe7b372fc7c9f5b5761a62285b998a10--wget-1.20.3_2.catalina.bottle.tar.gz
==> Pouring the cached bottle
==> Downloading https://homebrew.bintray.com/bottles/wget-1.20.3_2.catalina.bottle.tar.gz
Already downloaded: /Users/jonchang/Library/Caches/Homebrew/downloads/a160b20d674052d2077aa12a47eb037cbe7b372fc7c9f5b5761a62285b998a10--wget-1.20.3_2.catalina.bottle.tar.gz
==> Pouring the cached bottle
Error: uninitialized constant Cask::CaskLoader::FromURILoader::Cache
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:95:in `initialize'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:196:in `new'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:196:in `block in for'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:195:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:195:in `for'
/usr/local/Homebrew/Library/Homebrew/cask/cask_loader.rb:184:in `load'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:178:in `cask_exists_with_ref'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:59:in `block in to_resolved_formulae_to_casks'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `each'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `to_resolved_formulae_to_casks'
/usr/local/Homebrew/Library/Homebrew/cli/args.rb:72:in `resolved_formulae_casks'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:76:in `upgrade'
/usr/local/Homebrew/Library/Homebrew/brew.rb:112:in `<main>'
e3372e2a14dde3adab0423379a9de9b72a47d616 is the first bad commit
commit e3372e2a14dde3adab0423379a9de9b72a47d616
Author: Bo Anderson <mail@boanderson.me>
Date:   Tue Aug 18 00:23:23 2020 +0100

    Lazily require some heavy files

 Library/Homebrew/cask/cmd/--cache.rb               |  4 +--
 Library/Homebrew/cask/cmd/audit.rb                 |  5 ++--
 Library/Homebrew/cask/cmd/doctor.rb                |  5 ++--
 Library/Homebrew/cask/cmd/fetch.rb                 |  5 ++--
 Library/Homebrew/cask/cmd/info.rb                  |  3 ++-
 Library/Homebrew/cask/cmd/install.rb               |  2 ++
 Library/Homebrew/cask/cmd/internal_stanza.rb       |  2 ++
 Library/Homebrew/cask/cmd/reinstall.rb             |  1 +
 Library/Homebrew/cask/cmd/uninstall.rb             |  2 ++
 Library/Homebrew/cask/cmd/upgrade.rb               |  2 ++
 Library/Homebrew/cli/named_args.rb                 |  4 +++
 Library/Homebrew/cli/parser.rb                     |  1 -
 Library/Homebrew/dev-cmd/extract.rb                |  1 +
 .../Homebrew/extend/os/linux/extend/ENV/super.rb   |  2 +-
 Library/Homebrew/formulary.rb                      |  3 +++
 Library/Homebrew/global.rb                         |  9 +++----
 Library/Homebrew/tap.rb                            |  2 +-
 Library/Homebrew/test/cask/cmd/audit_spec.rb       |  1 +
 Library/Homebrew/test/dev-cmd/extract_spec.rb      | 29 ++++++++++++++--------
 .../test/support/helper/cask/install_helper.rb     |  2 ++
 .../helper/spec/shared_context/homebrew_cask.rb    |  1 +
 21 files changed, 57 insertions(+), 29 deletions(-)
bisect run success
1 Like

Will do, thank you so much!

Fixed in https://github.com/Homebrew/brew/pull/8750