8000 Delete `--package-rbi-generation` mode by jez · Pull Request #8662 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Delete --package-rbi-generation mode #8662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 29, 2025
Merged

Delete --package-rbi-generation mode #8662

merged 7 commits into from
Apr 29, 2025

Conversation

jez
Copy link
Collaborator
@jez jez commented Mar 11, 2025

Motivation

The --package-rbi-generation mode is proving difficult to maintain for a
couple reasons:

  • It initializes the packager options differently from the rest of the
    pipeline. This is important, because we need the GlobalState to have
    the right packager options so that namer can decide whether it wants
    to treat __package.rb files as packages and enter them into the
    symbol table, or leave them as normal Ruby files.

  • It does weird things with __package.rb files. It tries to make it
    seem like you're running with opts.stripePackages being false, but
    then do package-related things (e.g., findPackages).

  • It's going to complicate our attempts to interleave resolve and
    typecheck.

This feature never made it into use at Stripe, and never gained LSP
support. Also, we generally don't think this approach is the approach we'd
use if we were to revisit that: we think that we'd probably have a
"one RBI per package" approach, instead of "one RBI per transitive package
deps" approach, which would get rid a lot of the hacks around
"this symbol doesn't resolve" that have infected resolver right now.

This change deletes all but the code in packager/rbi_gen.{h,cc}. The RBI
generation code itself is useful to keep around because it has a bunch of
stuff which could be useful for simply generating RBIs from
GlobalState.

Test plan

  • Sorbet still builds
  • The existing tests assert that we didn't inadvertently break things we were
    not planning on touching
  • The rbi_gen.cc code is still being compiled via //main:sorbet so those
    build failures will show up in CI still

@jez jez requested a review from a team as a code owner March 11, 2025 23:18
@jez jez requested review from neilparikh and removed request for a team March 11, 2025 23:18
@jez jez marked this pull request as draft March 13, 2025 00:30
jez added 7 commits April 28, 2025 10:50
The `--package-rbi-generation` mode is proving difficult to maintain for
a couple reasons:

- It initializes the packager options differently from the rest of the
  pipeline. This is important, because we need the GlobalState to have
  the right packager options so that `namer` can decide whether it wants
  to treat `__package.rb` files as packages and enter them into the
  symbol table, or leave them as normal Ruby files.

- It does weird things with `__package.rb` files. It tries to make it
  seem like you're running with `opts.stripePackages` being false, but
  then do package-related things (e.g., `findPackages`).

- It's going to complicate our attempts to interleave resolve and
  typecheck.

This feature never made it into use at Stripe, and never gained LSP
support. Also, we generally don't think this approach is the approach
we'd use if we were to revisit that: we think that we'd probably have a
"one RBI per package" approach, instead of "one RBI per transitive
package deps" approach, which would get rid a lot of the hacks around
"this symbol doesn't resolve" that have infected resolver right now.

This change deletes all but the code in `packager/rbi_gen.{h,cc}`. The
RBI generation code itself is useful to keep around because it has a
bunch of stuff which could be useful for simply generating RBIs from
`GlobalState`.
The code in `packager/rbi_gen.*` will still be tested indirectly via the
`//packager:packager` library.

We could split it out, but then we'd have to make a whole job just to
test it and there's not that much code in the library in the first
place, so I'm not too worried about it being separate.
@jez jez force-pushed the jez-no-rbi-gen branch from d27c99d to cc724cd Compare April 28, 2025 17:53
@jez jez requested a review from froydnj April 29, 2025 18:31
@jez jez marked this pull request as ready for review April 29, 2025 18:31
Copy link
Contributor
@froydnj froydnj left a comment

Choose a reason for hiding this comment

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

We are removing the support, but we are leaving rbi_gen.cc?

@jez
Copy link
Collaborator Author
jez commented Apr 29, 2025

We are removing the support, but we are leaving rbi_gen.cc?

I don't need to remove it for any of the other packager/namer work, so I had left it so that it would at least keep building. Most of the code is pretty straightforward and could be a useful mechanism to effectively serialize a symbol table to an RBI.

If we want it gone too, I'm happy to remove it in a follow up.

@jez jez merged commit 64f118b into master Apr 29, 2025
14 checks passed
@jez jez deleted the jez-no-rbi-gen branch April 29, 2025 18:41
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
0