Skip to content

brew.sh: work around non-writable cache for lgtm commands.#21791

Merged
MikeMcQuaid merged 1 commit intomainfrom
lgtm_cache_sandbox
Mar 22, 2026
Merged

brew.sh: work around non-writable cache for lgtm commands.#21791
MikeMcQuaid merged 1 commit intomainfrom
lgtm_cache_sandbox

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

Under some e.g. AI sandboxes HOMEBREW_CACHE is not accessible but the current working directory's tmp is instead. In those cases, print a warning and automatically copy and use the other cache.


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

OpenAI Codex and manual review/testing/usage.


Copilot AI review requested due to automatic review settings March 21, 2026 09:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a workaround in brew.sh for environments where HOMEBREW_CACHE is not writable (e.g., some sandboxed/AI environments), automatically falling back to a repository-local cache and copying any existing API cache to avoid permission-related failures in brew lgtm-related workflows.

Changes:

  • Add a cache-writability check in brew.sh for audit/lgtm/style/tests, falling back to $HOMEBREW_REPOSITORY/tmp/cache and copying api/ cache contents.
  • Add an RSpec integration-style test covering the cache fallback behavior and warning output.
  • Remove sandbox setup instructions from AGENTS.md that are now intended to be handled automatically.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Library/Homebrew/brew.sh Implements the cache fallback + warning + best-effort API cache copy for selected commands.
Library/Homebrew/test/dev-cmd/lgtm_spec.rb Adds a spec that exercises the fallback path by invoking an isolated brew lgtm --help.
AGENTS.md Removes manual sandbox cache-copy instructions now superseded by the script behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Under some e.g. AI sandboxes HOMEBREW_CACHE is not accessible but
the current working directory's `tmp` is instead. In those cases,
print a warning and automatically copy and use the other cache.
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 22, 2026
Merged via the queue into main with commit f49f406 Mar 22, 2026
38 checks passed
@MikeMcQuaid MikeMcQuaid deleted the lgtm_cache_sandbox branch March 22, 2026 13:41
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.

3 participants