-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
dev-cmd/typecheck: Support typechecking in taps #18027
Conversation
```shell $ brew typecheck homebrew/bundle No sorbet/ directory found. Maybe you want to run 'srb init'? A type checker for Ruby Usage: srb Same as "srb t" srb (init | initialize) Initializes the `sorbet` directory srb rbi [options] Manage the `sorbet` directory srb (t | tc | typecheck) [options] Typechecks the code Options: -h, --help View help for this subcommand. --version Show version. For full help: https://sorbet.org Check https://docs.brew.sh/Typechecking for more information on how to resolve these errors. ```
Maybe we should run |
Any init should be explicit IMO. For this PR, we could do something like: raise UsageError, "Typechecking is not supported for the #{tap} tap" unless (tap.path/"sorbet").directory? or similar |
Additionally I was thinking about syncing |
Does it support symlinks? Ideally we reuse the brew Though maybe we need to do syncing for the Homebrew taps are somewhat unique in that they are all brew plugins rather than standalone projects. |
Something else to try: don't |
This makes sense to me. I still think it makes sense to tell a tap author how to get around this, though, but that doesn't need to block this PR.
This makes sense to me.
I don't think so. I agree with trying to use Homebrew's |
I tried this and it gives results. Not sure if they're correct results, but results all the same. |
c307886
to
399abae
Compare
On closer inspection with
|
Yes, this looks wrong. It shouldn't be checking |
I reset to the previous way in the follow-up commit. It's now more like what I'd expect, apart from Sorbet doesn't know about things like |
It actually looks somewhat correct to me: we don't have a "Homebrew/brew RBI" so it needs to check through Homebrew/brew to find definitions (AFAIK you can't configure Tapioca to generate RBIs from non-gems). In this case, the spec_helper.rb definition in homebrew-services is wrong. Unfortunately the error presents itself in a way that's perhaps confusing since it seems to run through homebrew-services first before Homebrew/brew so it marks Homebrew/brew as wrong rather than homebrew-services (ideally it would do Homebrew/brew first - maybe it supports multiple |
I reset to the diff --git a/Library/Homebrew/dev-cmd/typecheck.rb b/Library/Homebrew/dev-cmd/typecheck.rb
index d6c5e33500..490e41a520 100644
--- a/Library/Homebrew/dev-cmd/typecheck.rb
+++ b/Library/Homebrew/dev-cmd/typecheck.rb
@@ -101,7 +101,7 @@ module Homebrew
cd("sorbet") do
srb_exec += ["--file", "../#{args.file}"] if args.file
srb_exec += ["--dir", "../#{args.dir}"] if args.dir
- srb_exec += ["--dir", tap_dir.to_s] if tap_dir
+ srb_exec += ["--dir", HOMEBREW_LIBRARY_PATH.to_s, "--dir", tap_dir.to_s] if tap_dir
end
end
success = system(*srb_exec)
|
Might be picking up the |
OK, having removed that |
I have no idea how/if this is possible but: I almost wonder if somehow the tap approach needs to be:
|
This is the current (
Does this mean that we can't allow Sorbet's |
I don't know, maybe ignore that, I more mean that we'll need to ensure we have this "you're in a subdirectory of Homebrew/brew" approach so typing works as expected within the Homebrew ecosystem. |
c82f749
to
e46980d
Compare
I thought I had got further, copying the RBI files in the |
Looks like Sorbet internally sorts files by file size so the output we got from Given Tapioca only supports gems, the only other way I could think about would be a temporary directory that converts Homebrew to a gemfile, adds it to a fake gemfile along with copying Tapioca and its dependencies which then runs Basically: the tooling for this doesn't seem to exist yet so might have to settle for something "close enough". |
Yeah the exporting a fake gem feels way too hacky. I did have a look at Parlour generation for that but we probably don't care that much. |
e46980d
to
399abae
Compare
- This means we don't have to copy config files around, and users get instant results rather than having to run `srb init`.
399abae
to
feedc5c
Compare
- This could autocorrect files in Homebrew/brew when we should be targetting the tap, because of the weird hierarchy thing (#18027 (comment)). Co-authored-by: Bo Anderson <[email protected]>
de427d0
to
4e37436
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thanks @issyl0! Will hold off merging until after next tag 🔜 today.
This comment was marked as spam.
This comment was marked as spam.
1 similar comment
This comment was marked as spam.
This comment was marked as spam.
- This could autocorrect files in Homebrew/brew when we should be targetting the tap, because of the weird hierarchy thing (Homebrew#18027 (comment)). Co-authored-by: Bo Anderson <[email protected]>
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?typed: strict
in all (non-package) files in Homebrew organisation #17297.