Skip to content

Remove base64 gem and add Homebrew/NoBase64 cop - #23410

Merged
MikeMcQuaid merged 2 commits into
mainfrom
base64-unpack-migration
Aug 4, 2026
Merged

Remove base64 gem and add Homebrew/NoBase64 cop#23410
MikeMcQuaid merged 2 commits into
mainfrom
base64-unpack-migration

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member

This can now be done as all formulae which required base64 have been switched to native String#unpack1/Array#pack in Homebrew/homebrew-core#296594.

  • Revert "Restore base64 gem" (Restore base64 gem聽#23344): removes the gem from the Gemfile and the vendored bundle again. The autogenerated RBI commit from Restore base64 gem聽#23344 is not reverted as it was unrelated stanza drift. base64 (0.3.0) stays in Gemfile.lock specs/checksums as a transitive dependency of the optional ruby-prof gem, matching the state before Restore base64 gem聽#23344.

  • Add a Homebrew/NoBase64 cop so usage cannot creep back into formulae or casks. It flags require "base64" and any Base64 usage in Formula/Casks files in any tap (scoped with the same globs as Homebrew/NoFileutilsRmrf) and autocorrects simple cases to the same replacements used in Remove base64 gem requirement聽homebrew-core#296594:

    • require "base64" is removed
    • Base64.decode64(x) becomes x.unpack1("m")
    • Base64.strict_decode64(x) becomes x.unpack1("m0")
    • Base64.encode64(x) becomes [x].pack("m")
    • Base64.strict_encode64(x) becomes [x].pack("m0")

    Base64.urlsafe_* calls and compound expressions that would need parenthesising are flagged without autocorrection. Verified end to end on a scratch core formula: brew style reports the offences and brew style --fix applies the conversions above.


  • 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?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code Fable 5 with local review and testing.

Copilot AI review requested due to automatic review settings August 3, 2026 16:25

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 PR removes Homebrew鈥檚 direct dependency on the base64 gem (now that affected formulae have migrated to native String#unpack1/Array#pack) and adds a RuboCop cop to prevent Base64 usage from reappearing in formulae/casks across taps.

Changes:

  • Remove base64 from Library/Homebrew/Gemfile dependencies and delete the vendored base64 gem files.
  • Add Homebrew/NoBase64 RuboCop cop (with autocorrections for common encode64/decode64 patterns) and accompanying spec.
  • Wire the cop into RuboCop loading/config, and ignore vendored base64-* gem directories in .gitignore.

Reviewed changes

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

Show a summary per file
File Description
Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/base64-0.3.0/lib/base64.rb Removes vendored base64 implementation file.
Library/Homebrew/vendor/bundle/ruby/4.0.0/gems/base64-0.3.0/COPYING Removes vendored base64 licensing file.
Library/Homebrew/test/rubocops/no_base64_spec.rb Adds tests for the new Homebrew/NoBase64 cop.
Library/Homebrew/rubocops/no_base64.rb Introduces the Homebrew/NoBase64 cop and autocorrection logic.
Library/Homebrew/rubocops/all.rb Ensures the new cop file is required/registered.
Library/Homebrew/Gemfile.lock Drops base64 from direct dependency list.
Library/Homebrew/Gemfile Removes gem "base64" from vendored gem set.
Library/.rubocop.yml Configures Homebrew/NoBase64 include/exclude patterns and description.
.gitignore Adds base64-* to the list of vendored gems not committed.

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

Comment thread Library/Homebrew/rubocops/no_base64.rb
Comment thread Library/Homebrew/test/rubocops/no_base64_spec.rb
- This reverts commit 10bdd6b.
- All formulae that needed `base64` now use native
  `String#unpack1`/`Array#pack` after Homebrew/homebrew-core#296594
  so the vendored gem is no longer needed.
- Bump `VENDOR_VERSION` as the vendored gem set changed again.
- The `base64` gem is no longer vendored so formulae and casks must
  not use it; flag `require "base64"` and any `Base64` usage in
  `Formula`/`Casks` files.
- Autocorrect `decode64`/`strict_decode64` to `String#unpack1` and
  `encode64`/`strict_encode64` to `Array#pack`, matching the migration
  in Homebrew/homebrew-core#296594.
@MikeMcQuaid
MikeMcQuaid force-pushed the base64-unpack-migration branch from 9ff3db0 to 3dc3470 Compare August 4, 2026 08:37
@MikeMcQuaid
MikeMcQuaid enabled auto-merge August 4, 2026 09:57

@p-linnane p-linnane 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.

Nice!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit b36a624 Aug 4, 2026
68 of 69 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the base64-unpack-migration branch August 4, 2026 16:07
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