You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error message when failing to resolve package:pedantic include in analysis_options.yaml is not descriptive enough #3259
I don't seem to be able to repro - though I have some questions:
Do you know if the file might not have existed when you opened the project (eg. you later ran Pub Get and we didn't clear the error), or do you think the was there from the start?
Ca.n you reproduce it reliably?
Is your pubspec.yaml that references pedantic in the same folder as the analysis_options.yaml?
For unrelated reasons, I ran pub upgrade and discovered that I had an old
analyzer package associated with this work. Could that perhaps be a factor,
I wonder? Will see if I can get it to repro.
On Tue, Apr 6, 2021 at 10:49 AM Danny Tuppeny ***@***.***> wrote:
I don't seem to be able to repro - though I have some questions:
- Do you know if the file might not have existed when you opened the
project (eg. you later ran Pub Get and we didn't clear the error), or do
you think the was there from the start?
- Ca.n you reproduce it reliably?
- Is your pubspec.yaml that references pedantic in the same folder as
the analysis_options.yaml?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3259 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARWL6Y33ASSYP4XP5NNU4LTHNCTDANCNFSM42PFNNCQ>
.
In theory, any analyzer referenced by the project shouldn't impact the analyzer being used by the editor (we always run the snapshot from the SDK), so I suspect not related. Let me know if you can repro though (if you can share a project that is triggering it when you open it, that would be particularly useful).
I'll have a go on Windows too, in case that was a factor (though I suspect not).
This issue has been marked stale because it is tagged awaiting-info for 30 days with no activity. Remove the stale label or comment to prevent the issue being closed in 10 days.
Do you happen to know if it's when you're missing the packages locally (eg. fresh clone and haven't run pub get yet)? What version(s) of the SDKs do you tend to use?
I can't see any obvious causes in the code. If the file exists on disk during analysis ofcourse the error should never be generated. If it doesn't, when when the .packages or .dart_tool/package_config.json files are written it re-creates the analysis contexts which re-triggers analysis of this.
Sorry -- I know I'm a bit intermittent at replying here. This is the kind
of thing that only happens when I'm deep in the middle of solving an
unrelated problem, and it's hard to step out of the zone to reproduce. I
suspect it might have to do with changing branches of my codebase, perhaps
where the pub package versions are invalidated. I'll try and capture it if
I can.
On Tue, May 18, 2021 at 6:15 AM Danny Tuppeny ***@***.***> wrote:
Do you happen to know if it's when you're missing the packages locally
(eg. fresh clone and haven't run pub get yet)? What version(s) of the
SDKs do you tend to use?
I can't see any obvious causes in the code. If the file exists on disk
during analysis ofcourse the error should never be generated. If it
doesn't, when when the .packages or .dart_tool/package_config.json files
are written it re-creates the analysis contexts which re-triggers analysis
of this.
It might be useful to run with the analysis_server log
<https://dartcode.org/docs/logging/#analyzer> and/or analysis_server
instrumentation log
<https://dartcode.org/docs/logging/#analyzer-instrumentation> enabled,
and when you next see it grab a copy of those files so we can see if there
are any clues in there.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3259 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARWL63S27ELBICVCVGYSY3TOJR6XANCNFSM42PFNNCQ>
.
I just hit what seems like this problem myself, although what triggered it was a little weird so I'm not sure if it's the same for you.
I opened flutter_gallery and got the same error, even though I could see from the .packages/.dart_tool/package_config.json (and the dependencies tree) that everything was correct. I rigged the analyzer to include the full path of where it was looking for the file in the error message, and that did not match:
I found that I had a codeviewer_cli/.dart_tool/package_config.json file that referenced and old version of pedantic. It looks like that was a nested project that was removed (although the non-git files remained on my disk).
I'm able to reproduce this with a nested project like this:
If I fetch packages for both projects, I see the warning above because the analysis server seems to use the example/.dart_tool/package_config.json file to resolve the pedantic.
Whilst this initially seemed like a bug, I think actually it may be working as intended (although it's confusing). I don't believe it's using the wrong package file to analyze the analys_options file, I think it's analysing the file twice. Once in the context of the root project (which works, because it uses the package paths from the root project) and then again in the context of the nested project (since it walks up the tree and finds that anlaysis_options file, then tries to pare is using the nested projects package paths).
So although the way the error is reported looks like it's for the root project, it's actually for the context of a nested project.
@bwilkerson assuming this is working as expected, perhaps there's something we could tag onto the error message to make it clearer? Currently it says:
The include file package:pedantic/analysis_options.1.11.0.yaml in /Users/danny/Desktop/dart_application_2/analysis_options.yaml cannot be found.
Perhaps we could tag something onto the end when the analysis_options file is not inside the context? For example:
The include file package:pedantic/analysis_options.1.11.0.yaml in /Users/danny/Desktop/dart_application_2/analysis_options.yaml cannot be found when analyzing /Users/danny/Desktop/dart_application_2/example.
Yes, it's working as intended. At each directory for which either the package mapping (package_config.json) or analysis options are specified, the analyzer looks for the pair of files that specify the whole analysis context and uses the information in those files when analyzing the code in that directory.
I agree that the message could be more helpful, and I like your suggestion.
@timsneath let me know if you see this again once you're using an SDK that includes dart-lang/sdk@6d763b4. The error message will hopefully be clearer.
My guess is that either it's something similar to the above (like a nested project), or you've somehow ended up with a path to the pedantic library in .packages/.dart_tool/package_config.json that's not valid (although the only way I can come up with for that to happen is manually nuking your pub-cache - something I do now and then but I don't know if you do!).
The image shows you including package:lints/recommended.yaml, not lint (note the lack of an s), and I'm guessing that the file runner/.packages doesn't have an entry for lints.
When analyzing files in runner, the analyzer uses both the file runner/.packages and the file analysis_options.yaml. The analysis options file contains a URI for package:lints, but the .packages file doesn't contain a mapping for that package, which is what caused the error.
On Fri, Jun 11, 2021 at 12:46 PM Brian Wilkerson ***@***.***> wrote:
The image shows you including package:lints/recommended.yaml, not lint
(note the lack of an s), and I'm guessing that the file runner/.packages
doesn't have an entry for lints.
When analyzing files in runner, the analyzer uses both the file
runner/.packages and the file analysis_options.yaml. The analysis options
file contains a URI for package:lints, but the .packages file doesn't
contain a mapping for that package, which is what caused the error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3259 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARWL63TFX2UYHJQO7663UDTSJR27ANCNFSM42PFNNCQ>
.
@timsneath are you happy for me to close this as addressed by dart-lang/sdk@6d763b4 (including the folder in the error message), and if it comes up again and isn't explained by something like the above, we can re-open or file another issue?
changed the title [-]Can't find analysis_options.yaml in package:pedantic[/-][+]Error message when failing to resolve package:pedantic include in analysis_options.yaml is not descriptive enough[/+]on Jun 28, 2021
Activity
DanTup commentedon Apr 6, 2021
I don't seem to be able to repro - though I have some questions:
pubspec.yamlthat referencespedanticin the same folder as theanalysis_options.yaml?timsneath commentedon Apr 12, 2021
DanTup commentedon Apr 13, 2021
In theory, any analyzer referenced by the project shouldn't impact the analyzer being used by the editor (we always run the snapshot from the SDK), so I suspect not related. Let me know if you can repro though (if you can share a project that is triggering it when you open it, that would be particularly useful).
I'll have a go on Windows too, in case that was a factor (though I suspect not).
github-actions commentedon May 14, 2021
This issue has been marked stale because it is tagged awaiting-info for 30 days with no activity. Remove the stale label or comment to prevent the issue being closed in 10 days.
DanTup commentedon May 17, 2021
@timsneath have you seen this since? I tried to repro on Windows without any luck.
timsneath commentedon May 17, 2021
DanTup commentedon May 18, 2021
Do you happen to know if it's when you're missing the packages locally (eg. fresh clone and haven't run
pub getyet)? What version(s) of the SDKs do you tend to use?I can't see any obvious causes in the code. If the file exists on disk during analysis ofcourse the error should never be generated. If it doesn't, when when the
.packagesor.dart_tool/package_config.jsonfiles are written it re-creates the analysis contexts which re-triggers analysis of this.It might be useful to run with the analysis_server log and/or analysis_server instrumentation log enabled, and when you next see it grab a copy of those files so we can see if there are any clues in there.
timsneath commentedon Jun 2, 2021
DanTup commentedon Jun 9, 2021
I just hit what seems like this problem myself, although what triggered it was a little weird so I'm not sure if it's the same for you.
I opened
flutter_galleryand got the same error, even though I could see from the.packages/.dart_tool/package_config.json(and the dependencies tree) that everything was correct. I rigged the analyzer to include the full path of where it was looking for the file in the error message, and that did not match:I found that I had a
codeviewer_cli/.dart_tool/package_config.jsonfile that referenced and old version ofpedantic. It looks like that was a nested project that was removed (although the non-git files remained on my disk).I'm able to reproduce this with a nested project like this:
If I fetch packages for both projects, I see the warning above because the analysis server seems to use the
example/.dart_tool/package_config.jsonfile to resolve thepedantic.Whilst this initially seemed like a bug, I think actually it may be working as intended (although it's confusing). I don't believe it's using the wrong package file to analyze the analys_options file, I think it's analysing the file twice. Once in the context of the root project (which works, because it uses the package paths from the root project) and then again in the context of the nested project (since it walks up the tree and finds that anlaysis_options file, then tries to pare is using the nested projects package paths).
So although the way the error is reported looks like it's for the root project, it's actually for the context of a nested project.
@bwilkerson assuming this is working as expected, perhaps there's something we could tag onto the error message to make it clearer? Currently it says:
Perhaps we could tag something onto the end when the analysis_options file is not inside the context? For example:
2 remaining items
bwilkerson commentedon Jun 9, 2021
Yes, it's working as intended. At each directory for which either the package mapping (
package_config.json) or analysis options are specified, the analyzer looks for the pair of files that specify the whole analysis context and uses the information in those files when analyzing the code in that directory.I agree that the message could be more helpful, and I like your suggestion.
DanTup commentedon Jun 9, 2021
Great - adding that seems to make it much more obvious what was going on with my repro:
I'm not certain it's what Tim's hitting, but the message might at least help narrow it down next time it occurs.
[analyzer] Include analyzed context in include_file_not_found errors
DanTup commentedon Jun 9, 2021
@timsneath let me know if you see this again once you're using an SDK that includes dart-lang/sdk@6d763b4. The error message will hopefully be clearer.
My guess is that either it's something similar to the above (like a nested project), or you've somehow ended up with a path to the pedantic library in
.packages/.dart_tool/package_config.jsonthat's not valid (although the only way I can come up with for that to happen is manually nuking your pub-cache - something I do now and then but I don't know if you do!).timsneath commentedon Jun 11, 2021
Aha! I've triggered it:

bwilkerson commentedon Jun 11, 2021
Is there a
runner/.dart_tool/package_config.jsonfile? If so, does it specify a mapping to a version ofpackage:lintsthat includesrecommended.yaml?timsneath commentedon Jun 11, 2021
There's a
pubspec.lockand.packagesfolder that points to lint 1.2.0.I should note in passing that I'm not sure how that
runnerfolder got there (!)bwilkerson commentedon Jun 11, 2021
The image shows you including
package:lints/recommended.yaml, notlint(note the lack of ans), and I'm guessing that the filerunner/.packagesdoesn't have an entry forlints.When analyzing files in
runner, the analyzer uses both the filerunner/.packagesand the fileanalysis_options.yaml. The analysis options file contains a URI forpackage:lints, but the.packagesfile doesn't contain a mapping for that package, which is what caused the error.timsneath commentedon Jun 16, 2021
DanTup commentedon Jun 28, 2021
@timsneath are you happy for me to close this as addressed by dart-lang/sdk@6d763b4 (including the folder in the error message), and if it comes up again and isn't explained by something like the above, we can re-open or file another issue?
timsneath commentedon Jun 28, 2021
Yeah, totally fine. The error message will now make it much easier to diagnose (modulo confusion over lint vs. lints).
[-]Can't find analysis_options.yaml in package:pedantic[/-][+]Error message when failing to resolve package:pedantic include in analysis_options.yaml is not descriptive enough[/+]