-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
analysis_options.yaml "include:" not working for nested folders unless workspace root has a package config for the referenced package #56047
Comments
Labels: |
@davidmorgan can you confirm what commit I can use to repro this? I checked out your |
Oh, I see you pushed a fix for it. I reverted that fix, but I do see the Can you confirm which folder you have opened in VS Code, and whether the package is correctly in
|
I tried opening a simpler workspace that just has the macros folder
but no difference, the lint config still seems to be missing. Here's
It's possible I have a bad dart version, I'm using the SDK from main from the last time I happened to build it, I can try with a known-good SDK version if that helps. Thanks :) |
I was using a new bleeding-edge build I just grabbed from https://gsdview.appspot.com/dart-archive/channels/be/raw/latest/sdk/ Can you reproduce it without the SSH? I doubt it's related, but since we're seeing different behaviour it'd be good to eliminate some variables. |
Oh, interesting, local version works straight away
both local and remote are on the same VSCode version
and I don't see anything suspicious in the remote settings. Ooookay it gets even more interesting! I downloaded an SDK from the link you gave, and with that both work. But that's quite an old SDK? It's from Nov 2023. If I instead use a more recent one from https://gsdview.appspot.com/dart-archive/channels/main/raw/latest/sdk/ then again I see local VSCode works but remote doesn't. So it looks like it is related to some change in the SDK. |
Oh, I messed up here.. Firstly, I downloaded a new SDK but was actually still set to use the stable SDK. Secondly, I pasted a bad link here - I got the SDK from https://gsdview.appspot.com/dart-archive/channels/main/raw/latest/sdk/ ( So, I properly updated to the bleeding edge SDK I said I was using, and I do not see the lint. But I don't see it either in VS Code or I don't know why your results are less consistent, but I can at least try looking into the cause of this. |
It seems to be triggered by having another project in the workspace. I've reduced it to this... two projects in the workspace. One has a violation for that lint and the other has no code. Both of them import the lints. Analyzing the offending project on its own (both by opening it in VS Code itself, or This is running on current bleeding-edge code. |
Ah, I should have said, I was running "dart analyze" from inside I'm not actually sure what "dart analyze" is supposed to do if run from a folder enclosing multiple packages? From the "macros" folder:
which matches: with bleeding edge Dart, if I open VSCode remote to "macros" which has two packages, no lint is reported; if I open it to "macros/tool/dart_model_generator" which is just one package, the lint is reported. |
I would expect it to analyze everything, though I'm not certain (@bwilkerson?). Though the behaviour is the same in VS Code and still broken - if I open the one project I see the lint failure, and if I open the parent I do not. It should definitely work in that case. I think I've managed to reproduce this in a test, will continue debugging. |
@bwilkerson @pq I dug into this a little but I don't understand enough to know what the problem/fix is. What seems to happen is that when we're building the context roots, we get into
In the implementation of That source factory was created here from the workspace:
But I feel like there is a mismatch here. The "workspace" here seems to correspond to the root folder opened in my IDE (the analysis root sent by the client), which is So I feel like the fix is to change It's possible this is also the cause of #55732. |
@davidmorgan I updated the issue title to match what I believe to be the issue here.
It turns out that you don't even need a second project to repro this (besides the one being imported). I reduced my repo to just this: If you open the package itself, everything works - I believe Let me know if you're seeing any behaviour that doesn't seem to match this, in case I discovered a slightly different bug to the one you're seeing 😄 (I did re-test with macros and that does seem to match for me though). |
Yes, that looks like a minimal repro of what I'm seeing. Thanks :) |
So would I. Running |
…pace not handling includes See #56047 Change-Id: Ic61234cb9cdf30ac7d28989c77eff8048730e891 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372340 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com> Reviewed-by: Phil Quitslund <pquitslund@google.com>
Friendly ping, is this likely to be fixed soon please? @pq There isn't really a nice workaround if you're working on multiple packages, you have to either write the precise lint config you want in full or open lots of editor instances. Or if someone has a better workaround, please share :) |
Given the holidays next week, and the number of people taking vacation time around them, it probably won't happen until the week after at the earliest, but we are actively working to solve this issue. |
Noted, thanks for the update :) |
How we doing on this one, @pq? |
@keertip took a look and I think is on to a fix 🎉 |
Verified this fixes the issue for me, thank you :) |
Awesome. Thank you @keertip! And thanks @davidmorgan for the confirmation! 🙏 |
Am I understanding correctly that this is a regression in Dart 3.5.0? e.g. those of us with multiple packages in a repo (or at least the packages not being in the repo root), who also include things like package:lints or other analyzer_options won't see analysis results in VSC? If so that seems pretty common. :) Assuming I'm understanding correctly, is there a process to petition for a hot-fix in 3.5.1 :) Or maybe it would just help to have a bit of explanation here (or somewhere else) as to how to work-around. Thanks! |
Yes, it's about multiple packages workspaces, i.e. your IDE has a workspace root that is not a package root, in combination with The most obvious workaround is to point your IDE at a different SDK version, since it's the analyzer version that's running in your IDE that matters. The only workaround I know if you are stuck on a broken analyzer version is to copy the yaml instead of using the import, which is not fun at all. Hopefully someone from the analyzer team can fill in the rest :) |
Fixes #56047 Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/376500 Cherry-pick-request: #56457 Change-Id: I3cb5ee316e4fe5564c0e5234d08566fec84de759 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380205 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Kevin Chisholm <kevinjchisholm@google.com> Reviewed-by: Phil Quitslund <pquitslund@google.com>
Adding this to the root of my repo appears to work as a workaround: name: _
environment:
sdk: ^3.5.0
dev_dependencies:
very_good_analysis: ^6.0.0 |
FWIW there was a cherry-pick made for this fix at #56464 so it should show up in a future 3.5 hotfix release. |
I have an
analysis_options.yaml
usinginclude
:And it looks correct because if I "dart analyze" I get findings:
But I don't see any such info in VSCode. If I copy the config in place:
then I immediately see the finding in VSCode.
Any ideas please? I ran into this on the language repo and ended up giving up and just copying the whole config in
https://github.com/dart-lang/language/blob/main/working/macros/dart_model/analysis_options.yaml
and now I run into it again in the macros repo
https://github.com/dart-lang/macros/tree/main/pkgs/dart_model
with my pending PR that has some lint issues :)
@jakemac53 @devoncarew @DanTup any ideas please? :)
The text was updated successfully, but these errors were encountered: