`brew test-bot --only-cleanup-before` fails on `/usr/local` runners: cannot create `libexec`

Open
#24,663 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github-actions, macos, ruby
Domain
cli, testing

Research direction

Start with Keg.must_exist_subdirectories and Keg.must_be_writable_directories in keg.rb, then trace how Homebrew::TestBot::TestCleanup calls mkpath before determining files to purge. Compare that behavior with the directory creation in install.sh and how brew cleanup and brew doctor handle missing directories. Reproduce with brew test-bot --only-cleanup-before on a /usr/local runner; done when cleanup succeeds without the permission error.

Written by the indexing model from the issue text.

Description

brew doctor output
Not available: this fails on a GitHub-hosted `macos-15-intel` runner,
set up with Homebrew/actions/setup-homebrew, in a third-party tap's CI.

Reproduced in CI on a fresh brew main (7.0.14-67-gb43c73f823) via
setup-homebrew, which is equivalent to brew update; brew doctor
isn't available from the runner. Full log of the failing job (the
relevant excerpt is quoted below, as Actions logs expire):
https://github.com/zbeekman/homebrew-tap/actions/runs/44144423031/job/134255544412

Verification
  • I ran brew update twice and am still able to reproduce my issue.
  • I have supplied my brew doctor output above and it seems unrelated to my issue.
  • This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.
  • I did not use AI/LLM to create this issue, or I disclosed the tool and model used; I will answer maintainer questions myself without AI/LLM.
brew config output
Homebrew/brew 7.0.14-67-gb43c73f823
Homebrew/homebrew-core a18de1aa60a
Runner: GitHub-hosted macos-15-intel (HOMEBREW_PREFIX=/usr/local)
What were you trying to do (and why)?

Run the standard tap CI (brew test-bot --only-cleanup-before, then
--only-setup, --only-tap-syntax, --only-formulae) on GitHub's
macos-15-intel runner.

What happened (include all command output)?

Excerpt of the failing job's log (timestamps and colours removed):

+ brew test-bot --only-cleanup-before
==> Already trusted tap: zbeekman/tap
==> Using Homebrew/brew 7.0.14-67-gb43c73f823 (Merge pull request #24645 from Homebrew/own-sigstore-verifier)
==> Using Homebrew/homebrew-core a18de1aa60a (Merge pull request #300359 from Homebrew/bump-moon-2.5.3)
==> Testing zbeekman/homebrew-tap 5ad328f (Merge 3c960d61c41c365cbd7cd0b7a766c10c9423061d into 944b57b6587c4a5bacddf9483d77a8d71826038b):

==> Running CleanupBefore#run!
==> git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core reset --hard origin/main
==> sudo mv /Library/Frameworks/Python.framework /private/tmp/d20261117-2491-jmwaxw
==> brew cleanup --prune-prefix
==> git -C /usr/local/Homebrew/Library/Taps/zbeekman/homebrew-tap clean -ff -dx
==> Determining /usr/local files to purge...
##[error]Permission denied @ dir_s_mkdir - /usr/local/libexec
##[error]Process completed with exit code 1.

The same job passed earlier the same day on an older brew. It still
passes on macos-26 (/opt/homebrew) and in the Linux containers.

ae73120245 ("Clean up broken libexec symlinks") added libexec to
Keg.must_exist_subdirectories, which feeds
Keg.must_be_writable_directories. Homebrew::TestBot::TestCleanup
calls Keg.must_be_writable_directories.each(&:mkpath) before it
determines the files to purge. On this runner /usr/local is owned by
root and /usr/local/libexec does not exist, so mkpath fails.
install.sh, which keg.rb says to keep in sync with this list, does
not create libexec, so existing /usr/local installations won't have
it either.

Other users of these lists (brew cleanup, brew doctor) skip
directories that don't exist, so this seems limited to test-bot.

What did you expect to happen?

brew test-bot --only-cleanup-before succeeds, as it did before
ae73120245: either install.sh creates libexec (with the matching
ownership) or test-bot does not need to create it.

Step-by-step reproduction instructions (running brew commands)
# On a GitHub-hosted macos-15-intel runner, after
# Homebrew/actions/setup-homebrew:
brew test-bot --only-cleanup-before

Failing run: https://github.com/zbeekman/homebrew-tap/actions/runs/44144423031/job/134255544412

AI disclosure: the cause was traced and this issue was drafted with
Claude Code (Opus 5.5, high effort); I reviewed it before posting.

Dominant language
Ruby
Stars
50.3k
Forks
11.4k
Avg merge
14h 56m
Merged PRs (30d)
273

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Homebrew/brew

All issues in Homebrew/brew

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.