Skip to content

Reduce vendored gem dependencies - #23309

Merged
MikeMcQuaid merged 1 commit into
mainfrom
simplify-vendored-gems
Jul 28, 2026
Merged

Reduce vendored gem dependencies#23309
MikeMcQuaid merged 1 commit into
mainfrom
simplify-vendored-gems

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member
  • Replace addressable and public_suffix with Ruby's URI.
  • Inline JWS decoding and scoped warning filtering.
  • Remove unused Redcarpet and the largely unmaintained Pry backend.
  • Defer heavy runtime gems until their functionality is needed.
  • Guard startup and require boundaries against eager loading.

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.

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

OpenAI GPT 5.6 Sol max with local review and testing.


Copilot AI review requested due to automatic review settings July 26, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

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

Comment thread Library/Homebrew/os/mac/mach.rb
Comment thread Library/Homebrew/livecheck/livecheck.rb
Comment thread Library/Homebrew/downloadable.rb
@MikeMcQuaid
MikeMcQuaid force-pushed the simplify-vendored-gems branch 2 times, most recently from bd2f4c3 to e4d6f17 Compare July 26, 2026 13:29
@MikeMcQuaid
MikeMcQuaid enabled auto-merge July 26, 2026 13:50
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Jul 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jul 27, 2026
@MikeMcQuaid
MikeMcQuaid force-pushed the simplify-vendored-gems branch from e4d6f17 to bec1b1a Compare July 27, 2026 19:43
- 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.
@MikeMcQuaid
MikeMcQuaid force-pushed the simplify-vendored-gems branch from bec1b1a to eee8d94 Compare July 27, 2026 20:06
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Jul 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 28, 2026
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit e2f1384 Jul 28, 2026
78 of 85 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the simplify-vendored-gems branch July 28, 2026 08:12
@carlocab

Copy link
Copy Markdown
Member

This broke brew tap-info --installed --json=v1:

❯ /opt/homebrew/bin/brew tap-info --installed --json=v1
Error: uninitialized constant Homebrew::Trust
/opt/homebrew/Library/Homebrew/tap.rb:1173:in 'Tap#to_hash'
/opt/homebrew/Library/Homebrew/utils.rb:88:in 'block (2 levels) in Utils.parallel_map'
Please report this issue:
  https://docs.brew.sh/Troubleshooting

Looking at a fix now.

@botantony

Copy link
Copy Markdown
Member

There are 8 formulae in homebrew-core that require base64 gem (f.e. https://github.com/Homebrew/homebrew-core/actions/runs/30362816384/job/90309299442 fails because Ruby cannot import the module)

@MikeMcQuaid

Copy link
Copy Markdown
Member Author

@botantony Thanks, can you open a PR?

@botantony botantony mentioned this pull request Jul 28, 2026
8 tasks
@Firefishy

Firefishy commented Jul 28, 2026

Copy link
Copy Markdown

There are 8 formulae in homebrew-core that require base64 gem (f.e. https://github.com/Homebrew/homebrew-core/actions/runs/30362816384/job/90309299442 fails because Ruby cannot import the module)

An alternative for the 8 formulae is to switch them to using String#unpack1("m") which provides the same functionality without needing the base64 gem.

I am a novice, but happy to PR this if desired.

pull Bot pushed a commit to specialized806/brew that referenced this pull request Jul 28, 2026
@MikeMcQuaid

Copy link
Copy Markdown
Member Author

@Firefishy yes please!

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.

6 participants