Reduce vendored gem dependencies - #23309
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request reduces Homebrew’s vendored Ruby gem footprint and startup load by removing several bundled gems (e.g. Addressable/PublicSuffix, Warning, Pry, Redcarpet) and shifting some dependencies behind lazy require boundaries, while updating documentation/completions and adding tests around the new behaviour.
Changes:
- Remove vendored gem dependencies and their license metadata (Addressable/PublicSuffix, Warning, Pry, Redcarpet, etc.) and update Bundler load paths.
- Replace/adjust functionality to avoid those dependencies (e.g. warning filtering, URI parsing) and add/adjust tests for new behaviour.
- Tighten lazy-loading boundaries for heavier dependencies (e.g.
macho,plist, download queue) and add a helper check to prevent eager constant definition.
Reviewed changes
Copilot reviewed 39 out of 66 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| manpages/brew.1 | Removes --pry/HOMEBREW_PRY documentation from the generated manpage. |
| Library/Homebrew/warnings.rb | Replaces warning gem usage with an in-house warning filter/ignore mechanism. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/warning-1.6.0/MIT-LICENSE | Removes vendored Warning gem license file. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/warning-1.6.0/lib/warning.rb | Removes vendored Warning gem implementation. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/public_suffix-7.0.5/LICENSE.txt | Removes vendored PublicSuffix gem license file. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/public_suffix-7.0.5/lib/public_suffix/version.rb | Removes vendored PublicSuffix version file. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/public_suffix-7.0.5/lib/public_suffix/rule.rb | Removes vendored PublicSuffix rule implementation. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/public_suffix-7.0.5/lib/public_suffix/list.rb | Removes vendored PublicSuffix list implementation. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/public_suffix-7.0.5/lib/public_suffix/errors.rb | Removes vendored PublicSuffix errors. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/public_suffix-7.0.5/lib/public_suffix/domain.rb | Removes vendored PublicSuffix domain implementation. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/public_suffix-7.0.5/lib/public_suffix.rb | Removes vendored PublicSuffix entrypoint. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/addressable-2.9.0/LICENSE.txt | Removes vendored Addressable license file. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/addressable-2.9.0/lib/addressable/version.rb | Removes vendored Addressable version file. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/addressable-2.9.0/lib/addressable/template.rb | Removes vendored Addressable template implementation. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/addressable-2.9.0/lib/addressable/idna/native.rb | Removes vendored Addressable IDNA native implementation. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/addressable-2.9.0/lib/addressable/idna.rb | Removes vendored Addressable IDNA loader. |
| Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/addressable-2.9.0/lib/addressable.rb | Removes vendored Addressable entrypoint. |
| Library/Homebrew/vendor/bundle/bundler/setup.rb | Updates vendored Bundler setup $LOAD_PATH entries to reflect removed gems. |
| Library/Homebrew/test/warnings_spec.rb | Adds unit tests for warning ignore scoping/restoration. |
| Library/Homebrew/test/support/helper/cmd/brew-verify-undefined.rb | Extends startup/require-time constant checks to cover newly-deferred gems/constants. |
| Library/Homebrew/test/livecheck/livecheck_spec.rb | Removes specs for use_homebrew_curl? behaviour. |
| Library/Homebrew/test/global_spec.rb | Adjusts integration check for unnecessary dependency loading. |
| Library/Homebrew/test/dev-cmd/irb_spec.rb | Adds test asserting --pry is deprecated/raises. |
| Library/Homebrew/test/api_spec.rb | Adds tests for API lazy behaviour and URL-safe Base64 decoding helper. |
| Library/Homebrew/sorbet/tapioca/config.yml | Removes now-unneeded gem exclusions (e.g. public_suffix, redcarpet, coderay). |
| Library/Homebrew/sorbet/tapioca/compilers/rubocop.rb | Removes method_source dependency by using source_location and reading source lines. |
| Library/Homebrew/sorbet/tapioca/compilers/rubocop_cask_ast_stanza.rb | Removes method_source require to match dependency pruning. |
| Library/Homebrew/sorbet/rbi/gems/warning@1.6.0.rbi | Removes RBI for the removed Warning gem. |
| Library/Homebrew/sorbet/rbi/gems/reline@0.6.3.rbi | Removes RBI for removed vendored Reline gem. |
| Library/Homebrew/sorbet/rbi/gems/method_source@1.1.0.rbi | Removes RBI for removed MethodSource gem. |
| Library/Homebrew/sorbet/rbi/gems/io-console@0.8.2.rbi | Removes RBI for removed IO::Console gem entry. |
| Library/Homebrew/sorbet/rbi/gems/addressable@2.9.0.rbi | Removes RBI for removed Addressable gem. |
| Library/Homebrew/os/mac/mach.rb | Defers macho require and refines typing around Mach-O file wrappers. |
| Library/Homebrew/livecheck/strategy/git.rb | Replaces Addressable parsing with Ruby URI. |
| Library/Homebrew/livecheck/livecheck.rb | Removes brewed-curl auto-detection logic tied to registrable-domain parsing. |
| Library/Homebrew/ignorable.rb | Replaces warning-ignore wrapper with scoped Warning[:deprecated] toggling. |
| Library/Homebrew/Gemfile.lock | Drops removed gems from the lockfile. |
| Library/Homebrew/Gemfile | Removes gem entries/groups for removed gems (e.g. redcarpet, pry, method_source, addressable, warning). |
| Library/Homebrew/extend/os/mac/hardware/cpu.rb | Removes macho dependency by inlining CPU type constants. |
| Library/Homebrew/extend/os/mac/extend/pathname.rb | Lazily requires macho when wrapping Mach-O pathnames. |
| Library/Homebrew/env_config.rb | Marks HOMEBREW_PRY as deprecated/no-op. |
| Library/Homebrew/downloadable.rb | Replaces Concurrent::Set verification cache with a standard Set. |
| Library/Homebrew/dev-cmd/irb.rb | Deprecates --pry and removes the Pry backend, always exec’ing IRB. |
| Library/Homebrew/cask/artifact/pkg.rb | Lazily requires plist only when needed for choices files. |
| Library/Homebrew/api/internal.rb | Defers download-queue related requires and loosens download queue parameter defaults. |
| Library/Homebrew/api/formula.rb | Defers local_patch/download queue loading and makes queue optional unless enqueuing. |
| Library/Homebrew/api/cask.rb | Defers download queue loading and makes queue optional unless enqueuing. |
| Library/Homebrew/api.rb | Adds lazy API requires, avoids eager Base64 dependency via custom URL-safe decode, and defers download queue creation. |
| docs/Manpage.md | Removes --pry/HOMEBREW_PRY documentation from docs. |
| docs/Gemfile.lock | Removes redcarpet from docs lockfile. |
| docs/Gemfile | Removes redcarpet from docs dependencies. |
| completions/zsh/_brew | Removes --pry completion for brew irb. |
| completions/fish/brew.fish | Removes --pry completion for brew irb. |
| completions/bash/brew | Removes --pry completion for brew irb. |
| .licenses/bundler/warning.dep.yml | Removes license metadata for removed Warning gem. |
| .licenses/bundler/reline.dep.yml | Removes license metadata for removed Reline gem. |
| .licenses/bundler/public_suffix.dep.yml | Removes license metadata for removed PublicSuffix gem. |
| .licenses/bundler/pry.dep.yml | Removes license metadata for removed Pry gem. |
| .licenses/bundler/method_source.dep.yml | Removes license metadata for removed MethodSource gem. |
| .licenses/bundler/io-console.dep.yml | Removes license metadata for removed IO::Console gem. |
| .licenses/bundler/coderay.dep.yml | Removes license metadata for removed CodeRay gem. |
| .licenses/bundler/addressable.dep.yml | Removes license metadata for removed Addressable gem. |
Files not reviewed (6)
- Library/Homebrew/sorbet/rbi/gems/addressable@2.9.0.rbi: File type not supported
- Library/Homebrew/sorbet/rbi/gems/io-console@0.8.2.rbi: File type not supported
- Library/Homebrew/sorbet/rbi/gems/method_source@1.1.0.rbi: File type not supported
- Library/Homebrew/sorbet/rbi/gems/pry@0.16.0.rbi: File type not supported
- Library/Homebrew/sorbet/rbi/gems/reline@0.6.3.rbi: File type not supported
- Library/Homebrew/sorbet/rbi/gems/warning@1.6.0.rbi: File type not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bd2f4c3 to
e4d6f17
Compare
e4d6f17 to
bec1b1a
Compare
- Replace `addressable` and `public_suffix` with Ruby's `URI` while retaining brewed-curl host detection. - Inline JWS decoding and scoped warning filtering. - Keep Base64 only as ruby-prof's on-demand transitive dependency. - Remove unused Redcarpet and the largely unmaintained Pry backend. - Defer heavy runtime gems until their functionality is needed. - Resolve lazy type dependencies before Sorbet runtime checks. Hyperfine (`--warmup 10 --runs 30`, repeated in both orders): - `HOMEBREW_NO_AUTO_UPDATE=1 brew info --json=v2 jq`: 528.9 ms ± 21.1 ms on `origin/main` and 512.6 ms ± 16.2 ms here, a 3% speedup.
bec1b1a to
eee8d94
Compare
|
This broke Looking at a fix now. |
|
There are 8 formulae in homebrew-core that require |
|
@botantony Thanks, can you open a PR? |
An alternative for the 8 formulae is to switch them to using I am a novice, but happy to PR this if desired. |
|
@Firefishy yes please! |
addressableandpublic_suffixwith Ruby'sURI.Hyperfine (
--warmup 10 --runs 30, repeated in both orders):HOMEBREW_NO_AUTO_UPDATE=1 brew info --json=v2 jq: 528.9 ms ± 21.1 ms onorigin/mainand 512.6 ms ± 16.2 ms here, a 3% speedup.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?OpenAI GPT 5.6 Sol max with local review and testing.