Skip to content

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Aug 29, 2025

As promised in slack, this PR includes the changes necessary to finally brew install and brew uninstall using only the internal API.

To test, run:

$ rm -rf "$(brew --cache)/api”

$ export HOMEBREW_USE_INTERNAL_API=1

$ brew install abcde
✔︎ JSON API formula.arm64_sequoia.jws.json
✔︎ JSON API cask.arm64_sequoia.jws.json
✔︎ JSON API abcde.json
==> Fetching downloads for: abcde
✔︎ Bottle Manifest abcde (2.9.3_1)
✔︎ Bottle Manifest cdrtools (3.02a09)
✔︎ Bottle cdrtools (3.02a09)
✔︎ Bottle Manifest eye-d3 (0.9.8)
✔︎ Bottle eye-d3 (0.9.8)
✔︎ Bottle Manifest glyr (1.0.10_3)
✔︎ Bottle glyr (1.0.10_3)
✔︎ Bottle Manifest libdiscid (0.6.5)
✔︎ Bottle libdiscid (0.6.5)
✔︎ Bottle Manifest mkcue (1)
✔︎ Bottle mkcue (1)
✔︎ Bottle Manifest berkeley-db@5 (5.3.28_1)
✔︎ Bottle Manifest gdbm (1.26)
✔︎ Bottle gdbm (1.26)
✔︎ Bottle Manifest perl (5.40.2)
✔︎ Bottle Manifest libao (1.2.2)
✔︎ Bottle libao (1.2.2)
✔︎ Bottle Manifest vorbis-tools (1.4.3)
✔︎ Bottle vorbis-tools (1.4.3)
✔︎ Bottle abcde (2.9.3_1)
✔︎ Bottle perl (5.40.2)
✔︎ Bottle berkeley-db@5 (5.3.28_1)
==> Installing dependencies for abcde: cdrtools, eye-d3, glyr, libdiscid, mkcue, berkeley-db@5, gdbm, perl, libao and vorbis-tools
==> Installing abcde dependency: cdrtools
==> Pouring cdrtools--3.02a09.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/cdrtools/3.02a09: 210 files, 6.3MB
==> Installing abcde dependency: eye-d3
==> Pouring eye-d3--0.9.8.all.bottle.tar.gz
🍺  /opt/homebrew/Cellar/eye-d3/0.9.8: 151 files, 1014KB
==> Installing abcde dependency: glyr
==> Pouring glyr--1.0.10_3.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/glyr/1.0.10_3: 18 files, 358.7KB
==> Installing abcde dependency: libdiscid
==> Pouring libdiscid--0.6.5.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libdiscid/0.6.5: 12 files, 160.0KB
==> Installing abcde dependency: mkcue
==> Pouring mkcue--1.arm64_sequoia.bottle.2.tar.gz
🍺  /opt/homebrew/Cellar/mkcue/1: 7 files, 83.7KB
==> Installing abcde dependency: berkeley-db@5
==> Pouring [email protected]_1.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/berkeley-db@5/5.3.28_1: 5,272 files, 86.4MB
==> Installing abcde dependency: gdbm
==> Pouring gdbm--1.26.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/gdbm/1.26: 25 files, 1MB
==> Installing abcde dependency: perl
==> Pouring perl--5.40.2.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/perl/5.40.2: 2,785 files, 69.8MB
==> Installing abcde dependency: libao
==> Pouring libao--1.2.2.arm64_sequoia.bottle.3.tar.gz
🍺  /opt/homebrew/Cellar/libao/1.2.2: 56 files, 332.5KB
==> Installing abcde dependency: vorbis-tools
==> Pouring vorbis-tools--1.4.3.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/vorbis-tools/1.4.3: 20 files, 665.2KB
==> Installing abcde
==> Pouring abcde--2.9.3_1.arm64_sequoia.bottle.tar.gz
🍺  /opt/homebrew/Cellar/abcde/2.9.3_1: 295 files, 3.2MB
==> Running `brew cleanup abcde`...
==> No outdated dependents to upgrade!

$ ❯ brew uninstall abcde
==> Downloading https://formulae.brew.sh/api/cask.jws.json
Uninstalling /opt/homebrew/Cellar/abcde/2.9.3_1... (295 files, 3.2MB)
==> Autoremoving 10 unneeded formulae:
berkeley-db@5
cdrtools
eye-d3
gdbm
glyr
libao
libdiscid
mkcue
perl
vorbis-tools
Uninstalling /opt/homebrew/Cellar/glyr/1.0.10_3... (18 files, 358.7KB)
Uninstalling /opt/homebrew/Cellar/vorbis-tools/1.4.3... (20 files, 665.2KB)
Uninstalling /opt/homebrew/Cellar/mkcue/1... (7 files, 83.7KB)
Uninstalling /opt/homebrew/Cellar/perl/5.40.2... (2,785 files, 69.8MB)
Uninstalling /opt/homebrew/Cellar/libdiscid/0.6.5... (12 files, 160.0KB)
Uninstalling /opt/homebrew/Cellar/cdrtools/3.02a09... (210 files, 6.3MB)
Uninstalling /opt/homebrew/Cellar/eye-d3/0.9.8... (151 files, 1014KB)
Uninstalling /opt/homebrew/Cellar/libao/1.2.2... (56 files, 332.5KB)
Uninstalling /opt/homebrew/Cellar/gdbm/1.26... (25 files, 1MB)
Uninstalling /opt/homebrew/Cellar/berkeley-db@5/5.3.28_1... (5,272 files, 86.4MB)

$ tree "$(brew --cache)/api"
/Users/rylanpolster/Library/Caches/Homebrew/api
├── cask_names.txt
├── cask.jws.json
├── formula
│   ├── abcde.json
│   ├── autoconf.json
│   ├── automake.json
│   ├── [email protected]
│   ├── bison.json
│   ├── ca-certificates.json
│   ├── cdrtools.json
│   ├── cmake.json
│   ├── dvdrtools.json
│   ├── eye-d3.json
│   ├── flac.json
│   ├── gdbm.json
│   ├── gettext.json
│   ├── gh.json
│   ├── glib.json
│   ├── glyr.json
│   ├── lame.json
│   ├── libao.json
│   ├── libdiscid.json
│   ├── libogg.json
│   ├── libtool.json
│   ├── libunistring.json
│   ├── libvorbis.json
│   ├── m4.json
│   ├── meson.json
│   ├── mkcue.json
│   ├── mpdecimal.json
│   ├── ninja.json
│   ├── [email protected]
│   ├── pcre2.json
│   ├── perl.json
│   ├── pkgconf.json
│   ├── python-setuptools.json
│   ├── [email protected]
│   ├── [email protected]
│   ├── readline.json
│   ├── smake.json
│   ├── sqlite.json
│   ├── texinfo.json
│   ├── vorbis-tools.json
│   └── xz.json
├── formula_aliases.txt
├── formula_names.txt
└── internal
    ├── cask.arm64_sequoia.jws.json
    └── formula.arm64_sequoia.jws.json

3 directories, 47 files

Importantly, the full formula.jws.json file was not downloaded during this process.

@Rylan12 Rylan12 marked this pull request as draft August 29, 2025 09:23
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.

Thanks! A few comments. I think stubs should only be needed during the brew install/brew upgrade/maybe brew reinstall paths as most anything else will be either

  1. triggering an installation
  2. can use a formula from the Cellar

@@ -718,11 +718,14 @@ def self.autoremove(dry_run: false)
# the cache of installed formulae may no longer be valid.
Formula.clear_cache unless dry_run

formulae = Formula.installed
formulae = Formula.installed(prefer_stub: true)
Copy link
Member

Choose a reason for hiding this comment

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

Anything dealing with installed formulae should just be able to use the formula from the Cellar rather than a stub?

Comment on lines +1070 to +1071
json_formula = if Homebrew::EnvConfig.use_internal_api?
Homebrew::API::Formula.formula_json(name)
Copy link
Member

Choose a reason for hiding this comment

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

This definitely makes sense.

@@ -26,7 +26,7 @@ def find_some_installed_dependents(kegs, casks: [])
kegs_by_source = kegs.group_by do |keg|
# First, attempt to resolve the keg to a formula
# to get up-to-date name and tap information.
f = keg.to_formula
f = keg.to_formula(prefer_stub: true)
Copy link
Member

Choose a reason for hiding this comment

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

Same deal with kegs: they should be able to use the formula file they have internally.

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