Skip to content

Load casks from the internal API#21662

Open
Rylan12 wants to merge 2 commits intomainfrom
load-casks-from-internal-api
Open

Load casks from the internal API#21662
Rylan12 wants to merge 2 commits intomainfrom
load-casks-from-internal-api

Conversation

@Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Mar 4, 2026

This PR primarily enables installing casks from the internal API via HOMEBREW_REALLY_USE_INTERNAL_API. It's essentially the exact same implementation as for Formulae, and seems to work from preliminary local testing.

In addition, I've added a new #loaded_from_internal_api? method to Formula and Cask that gates some minor functionality differences between the internal and non-internal APIs.

These two changes are somewhat coupled together, which is why I've done it in a single PR. I've split up the commits into a formula commit and a cask commit, which may make reviewing a bit easier. If it's still too much, I can spend more time getting them split up.

Copilot AI review requested due to automatic review settings March 4, 2026 04:42
Copy link
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

Enables loading/installing casks from the internal API when HOMEBREW_REALLY_USE_INTERNAL_API is set, mirroring the existing formula internal-API path and tracking whether a package was loaded from the internal API for small behavioral differences (e.g., messaging and gating some hash generation).

Changes:

  • Add loaded_from_internal_api? to Formula and Cask and persist loaded_from_internal_api into install receipts/tabs.
  • Teach cask API loader and internal API cache to build CaskStruct objects from the internal API (including caching tap git head).
  • Update tab/cask tab string output and expand test coverage + fixtures for the new receipt field.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Library/Homebrew/test/tab_spec.rb Adds assertions/matcher and new Tab#to_s expectations for internal API installs.
Library/Homebrew/test/support/fixtures/receipt.json Adds loaded_from_internal_api to receipt fixture.
Library/Homebrew/test/support/fixtures/cask_receipt.json Adds loaded_from_internal_api to cask receipt fixture.
Library/Homebrew/test/formulary_spec.rb Asserts formulae loaded from (public) API are not marked as internal.
Library/Homebrew/test/formula_spec.rb Adds Formula#specified_path test for internal API path behavior.
Library/Homebrew/test/cask/tab_spec.rb Updates cask tab serialization and string output expectations for internal API installs.
Library/Homebrew/test/cask/info_spec.rb Adds brew info output coverage for an internally-loaded cask install receipt.
Library/Homebrew/test/cask/cask_spec.rb Asserts casks loaded from (public) API are not marked as internal.
Library/Homebrew/test/cask/cask_loader/from_api_loader_spec.rb Adds expectation for loaded_from_internal_api? == false in API loader spec.
Library/Homebrew/tab.rb Persists and prints loaded_from_internal_api in tabs/receipts.
Library/Homebrew/sorbet/rbi/dsl/formula.rbi Adds RBI for Formula#loaded_from_internal_api?.
Library/Homebrew/formulary.rb Propagates an internal_api: flag into API-loaded formula classes.
Library/Homebrew/formula_installer.rb Writes loaded_from_internal_api into the install tab during bottle pours.
Library/Homebrew/formula.rb Adds loaded_from_internal_api?, adjusts specified_path, and gates to_hash_with_variations.
Library/Homebrew/cask/tab.rb Persists and prints loaded_from_internal_api in cask tabs.
Library/Homebrew/cask/cask_loader.rb Adds internal-API struct loading path and passes internal flag into cask instances.
Library/Homebrew/cask/cask.rb Adds loaded_from_internal_api? and gates to_hash_with_variations.
Library/Homebrew/api/internal.rb Adds internal cask struct caching and exposes internal cask tap git head.
Files not reviewed (1)
  • Library/Homebrew/sorbet/rbi/dsl/formula.rbi: Language not supported

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

@Rylan12 Rylan12 force-pushed the load-casks-from-internal-api branch from 10da407 to e1ad0c3 Compare March 4, 2026 04:56
@Rylan12
Copy link
Member Author

Rylan12 commented Mar 4, 2026

Going to stop for the night, but the main to-do item is verifying that we can read the internal API JSON files in .metadata directories for installed casks.

I haven't tested yet, but I believe this will cause issues with running brew install --cask foo while using the internal API, and then brew uninstall foo while not using the internal API.

Edit: uninstall doesn't seem to work at all right now, so that's something to work on

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good when working!

Is the plan still that we will eventually merge the formula and cask files?

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