Skip to content

sorbet: move sorbet/ to project root#22173

Draft
dduugg wants to merge 7 commits intomainfrom
move-sorbet-to-project-root
Draft

sorbet: move sorbet/ to project root#22173
dduugg wants to merge 7 commits intomainfrom
move-sorbet-to-project-root

Conversation

@dduugg
Copy link
Copy Markdown
Member

@dduugg dduugg commented May 7, 2026

Summary

  • Moves Library/Homebrew/sorbet/sorbet/ at the project root to address sorbet/sorbet#9808, where Sorbet's LSP server silently skips RBI shim files when sorbet/ is not a direct subdirectory of the working directory (the project root in editor setups).
  • Updates sorbet/config to pass --dir=Library/Homebrew explicitly so srb tc still type-checks the right source tree from the project root.
  • Updates brew typecheck to cd to HOMEBREW_REPOSITORY (project root) instead of HOMEBREW_LIBRARY_PATH, and adds a with_env("TMPDIR" => ...) guard to prevent a Sorbet SIGSEGV caused by Homebrew's build TMPDIR (/private/tmp).
  • Adds sorbet/.rubocop.yml inheriting from Library/.rubocop.yml so the moved tapioca compiler files continue to receive the standard Homebrew RuboCop configuration.
  • Updates path references in Library/.rubocop.yml, .gitignore, and CI workflows accordingly.

Caveats

This is an inherently disruptive change — it renames ~290 files and touches CI, .gitignore, and rubocop config. Even if it resolves the LSP issues described in sorbet/sorbet#9808, it may not be desirable. In particular:

  • LSP fix needs manual confirmation. The upstream Sorbet issue has not been resolved; this is a workaround. It should be tested with an actual editor (e.g. VS Code with the Sorbet extension or ruby-lsp) starting from the project root to confirm that RBI shims are now picked up correctly.
  • brew typecheck --update runs tapioca from the project root. The tapioca config and compilers reference paths relative to Library/Homebrew/; these have been verified to work, but deserve extra scrutiny.
  • --changed style checks now span two config domains. A new sorbet/.rubocop.yml bridges this, but it's an additional config file to maintain.

Test plan


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Claude Code (claude-sonnet-4-6) was used to plan and implement the directory relocation, debug Sorbet SIGSEGV issues caused by TMPDIR, identify the correct --dir and --ignore path semantics, and fix RuboCop config inheritance for the moved files. All changes were reviewed and brew lgtm --online was run to verify correctness.

dduugg added 6 commits May 7, 2026 15:43
Moves `Library/Homebrew/sorbet/` to `sorbet/` at the project root so
that Sorbet's LSP server can auto-discover the config and rbi shims
without needing to be started from `Library/Homebrew/`. This addresses
sorbet/sorbet#9808, where the LSP server silently skips RBI shim files
when the working directory doesn't contain a `sorbet/` subdirectory.

Updates `sorbet/config` to pass `--dir=Library/Homebrew` explicitly so
Sorbet still type-checks the right source tree. Adjusts `typecheck.rb`
to `cd` to `HOMEBREW_REPOSITORY` (project root) instead of
`HOMEBREW_LIBRARY_PATH`, and adds a `with_env("TMPDIR" => ...)` guard
to prevent a Sorbet SIGSEGV caused by Homebrew's build TMPDIR.

Also adds `sorbet/.rubocop.yml` inheriting from `Library/.rubocop.yml`
so the moved tapioca compiler files continue to receive the standard
Homebrew RuboCop configuration, and updates path references in
`Library/.rubocop.yml` and the CI workflows accordingly.
Auto-corrected by `brew style --fix --changed`:
- Use `%w[]` word arrays in constants
- Prefer `exclude?` over `!include?`
- Also applies the config changes from the previous commit
After moving sorbet/ to the project root, `require_relative "../../../global"`
in compilers three levels deep now resolves to the project root rather than
Library/Homebrew/. Update all relative paths to include the Library/Homebrew/
segment, and replace `require "sorbet/tapioca/utils"` (which relied on
Library/Homebrew being in $LOAD_PATH) with `require_relative "../utils"`.
Library/.rubocop.yml should not reference paths outside Library/ via `..`.
Move the AllCops/Exclude for auto-generated RBI files and the
Homebrew/NegateInclude Exclude for tapioca compilers into sorbet/.rubocop.yml,
where paths are naturally relative to the sorbet/ directory.
- `style.rb`: include `sorbet/` in the default full scan alongside
  `Library/Homebrew/`, so `brew style` without arguments catches
  violations in tapioca compiler files.
- `config_spec.rb`: fix the relative path to `sorbet/tapioca/config.yml`
  (now five levels up from the test file rather than three).
@dduugg
Copy link
Copy Markdown
Member Author

dduugg commented May 8, 2026

No need to review/merge at this time, as it doesn't resolve the LSP navigation issues. I'm keeping this open for visibility & discussion with the sorbet folks, though feel free to close if it's annoying/distracting to have an open unactionable PR.

The Sorbet LSP requires a single --dir input; having both
--dir=Library/Homebrew and --dir=sorbet/rbi crashes the server.
Using --dir=. also segfaults due to the volume of files scanned.

Keep sorbet/config and sorbet/tapioca/ at the project root (so the
LSP can discover the config), but move the auto-generated RBI shims
back under Library/Homebrew/sorbet/rbi/ so a single --dir=Library/Homebrew
satisfies both the CLI typechecker and the LSP.

Update all references: rubocop configs, typecheck.rb, workflows,
and docs.
Copy link
Copy Markdown
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.

I would be OK with this if it fixes the issues.

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