Skip to content

untap: require CaskLoader - #23614

Merged
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
capruxel:fix-untap-cask-loader
Aug 22, 2026
Merged

untap: require CaskLoader#23614
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
capruxel:fix-untap-cask-loader

Conversation

@capruxel

Copy link
Copy Markdown
Contributor

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

While trying to remove kegworks-app/kegworks, I found that brew untap fails when the tap has an installed cask.

Reproduction

On the current main branch:

brew tap kegworks-app/kegworks
brew install --cask kegworks-app/kegworks/sikarugir
brew untap kegworks-app/kegworks

The final command fails with:

Error: uninitialized constant Cask::CaskLoader
/opt/homebrew/Library/Homebrew/cmd/untap.rb:132:in 'block in Homebrew::Cmd::Untap#installed_casks_for'
/opt/homebrew/Library/Homebrew/cmd/untap.rb:128:in 'Array#each'
/opt/homebrew/Library/Homebrew/cmd/untap.rb:128:in 'Enumerable#filter_map'
/opt/homebrew/Library/Homebrew/cmd/untap.rb:128:in 'Homebrew::Cmd::Untap#installed_casks_for'

From what I can tell, installed_casks_for calls Cask::CaskLoader.load(...) while checking installed casks, but does not load cask/cask_loader before using it.

This change loads cask/cask_loader inside installed_casks_for, where Cask::CaskLoader is used, and updates the existing untap integration test. The test now installs a cask from the test tap and uses brew untap --force in a fresh process to exercise the same installed-cask path without requiring interactive confirmation.

This may be related to the recent Cask lazy-loading changes in #23560. Similar Cask::CaskLoader loading regressions were addressed in #23566 and #23587.

Testing

I verified the regression with a red/green test cycle:

  • without require "cask/cask_loader", the integration test fails with uninitialized constant Cask::CaskLoader;
  • with the require restored, the test passes.

I also ran:

./bin/brew tests --only=cmd/untap
./bin/brew lgtm --online

Both completed successfully.

AI/LLM disclosure

ChatGPT (GPT-5.6 Sol) was used to assist with investigating the failure, reviewing related Homebrew changes, understanding the contribution process, and developing the regression test. I reviewed the code and prose myself and reproduced and tested the changes locally.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MikeMcQuaid
MikeMcQuaid enabled auto-merge August 22, 2026 08:10
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 22, 2026
Merged via the queue into Homebrew:main with commit 1bbe93e Aug 22, 2026
47 checks passed
@capruxel
capruxel deleted the fix-untap-cask-loader branch August 22, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants