Skip to content

Require sorbet-runtime from each checker entrypoint#67

Closed
beauraF wants to merge 1 commit into
rubyatscale:mainfrom
beauraF:require-sorbet-runtime-in-checkers
Closed

Require sorbet-runtime from each checker entrypoint#67
beauraF wants to merge 1 commit into
rubyatscale:mainfrom
beauraF:require-sorbet-runtime-in-checkers

Conversation

@beauraF
Copy link
Copy Markdown

@beauraF beauraF commented May 28, 2026

Summary

  • packwerk 3.3.0 dropped its runtime dependency on sorbet-runtime
  • The README documents adding individual checkers to packwerk.yml's require: list (e.g. - packwerk/privacy/checker), which bypasses lib/packwerk-extensions.rb — the only place currently calling require 'sorbet-runtime'
  • Without sorbet-runtime preloaded, evaluating a checker file hits extend T::Sig / T.let before T exists and fails with uninitialized constant Packwerk::Privacy::T (NameError)

Fix

Add require 'sorbet-runtime' at the top of each documented entrypoint:

  • lib/packwerk/privacy/checker.rb
  • lib/packwerk/visibility/checker.rb
  • lib/packwerk/folder_privacy/checker.rb
  • lib/packwerk/layer/checker.rb

The require cascades through package.rb / validator.rb (and config.rb / layers.rb for layer), which also use T:: constants. sorbet-runtime is already declared as a runtime gemspec dependency, so it's always in the bundle. Existing umbrella entrypoint and test helper continue to work unchanged.

Reproduction

Before this change, with packwerk 3.3.0 in the bundle:

ruby -Ilib -rpackwerk -e "require 'packwerk/privacy/checker'"
# => lib/packwerk/privacy/package.rb:7: uninitialized constant Packwerk::Privacy::T (NameError)

After:

ruby -Ilib -rpackwerk -e "require 'packwerk/privacy/checker'"
# => exits 0

packwerk 3.3.0 dropped its runtime dependency on sorbet-runtime. The
README documents adding individual checkers to packwerk.yml's `require:`
list (e.g. `- packwerk/privacy/checker`), which bypasses the umbrella
`packwerk-extensions.rb` entrypoint where `require 'sorbet-runtime'`
currently lives.

Once packwerk no longer pulls sorbet-runtime in for us, evaluating a
checker file hits `extend T::Sig` / `T.let` before `T` is defined and
fails with `uninitialized constant Packwerk::Privacy::T (NameError)`.

Load sorbet-runtime at the top of each documented entrypoint so
individual checker requires are self-sufficient. The require cascades
through `package.rb`, `validator.rb`, etc., which also use `T::` constants.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-project-automation github-project-automation Bot moved this to Triage in Modularity May 28, 2026
@beauraF beauraF marked this pull request as ready for review May 28, 2026 08:44
@beauraF beauraF requested a review from a team as a code owner May 28, 2026 08:44
Copy link
Copy Markdown
Contributor

@dduugg dduugg left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Let's follow the lead of upstream and migrate to RBS comments instead, what do you think? #68

@dduugg dduugg closed this May 29, 2026
@github-project-automation github-project-automation Bot moved this from Triage to Done in Modularity May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants