Skip to content

Error message when failing to resolve package:pedantic include in analysis_options.yaml is not descriptive enough #3259

Closed

Description

@timsneath

See screenshot.

This used to occur regularly, but had gone away for some months. Now it's back again. Could this be a regression?

The include file package:pedantic/analysis_options.yaml in c:\src\win32\analysis_options.yaml cannot be found.

image

Activity

  1. DanTup commented on Apr 6, 2021

    @DanTup
    Member

    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?
  2. added
    awaiting infoRequires more information from the customer to progress
    on Apr 6, 2021
  3. timsneath commented on Apr 12, 2021

    @timsneath
    ContributorAuthor
  4. DanTup commented on Apr 13, 2021

    @DanTup
    Member

    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).

  5. github-actions commented on May 14, 2021

    @github-actions

    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.

  6. DanTup commented on May 17, 2021

    @DanTup
    Member

    @timsneath have you seen this since? I tried to repro on Windows without any luck.

  7. timsneath commented on May 17, 2021

    @timsneath
    ContributorAuthor
  8. DanTup commented on May 18, 2021

    @DanTup
    Member

    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 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.

  9. timsneath commented on Jun 2, 2021

    @timsneath
    ContributorAuthor
  10. DanTup commented on Jun 9, 2021

    @DanTup
    Member

    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:

    Screenshot 2021-06-09 at 11 56 55

    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:

    foo/
        pubspec.yaml <-- references pedantic 1.11.0
        analysis_options.yaml <-- imports package:pedantic/analysis_options.1.11.0.yaml
    
        example/
            pubspec.yaml <-- references pedantic 1.8.0
    

    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.

  11. added
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    and removed
    awaiting infoRequires more information from the customer to progress
    on Jun 9, 2021
  12. 2 remaining items

  13. bwilkerson commented on Jun 9, 2021

    @bwilkerson

    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.

  14. DanTup commented on Jun 9, 2021

    @DanTup
    Member

    Great - adding that seems to make it much more obvious what was going on with my repro:

    Screenshot 2021-06-09 at 16 21 16

    I'm not certain it's what Tim's hitting, but the message might at least help narrow it down next time it occurs.

  15. DanTup commented on Jun 9, 2021

    @DanTup
    Member

    @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!).

  16. timsneath commented on Jun 11, 2021

    @timsneath
    ContributorAuthor

    Aha! I've triggered it:
    image

  17. bwilkerson commented on Jun 11, 2021

    @bwilkerson

    Is there a runner/.dart_tool/package_config.json file? If so, does it specify a mapping to a version of package:lints that includes recommended.yaml?

  18. timsneath commented on Jun 11, 2021

    @timsneath
    ContributorAuthor

    There's a pubspec.lock and .packages folder that points to lint 1.2.0.

    I should note in passing that I'm not sure how that runner folder got there (!)

  19. bwilkerson commented on Jun 11, 2021

    @bwilkerson

    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.

  20. added
    awaiting infoRequires more information from the customer to progress
    on Jun 12, 2021
  21. timsneath commented on Jun 16, 2021

    @timsneath
    ContributorAuthor
  22. DanTup commented on Jun 28, 2021

    @DanTup
    Member

    @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?

  23. timsneath commented on Jun 28, 2021

    @timsneath
    ContributorAuthor

    Yeah, totally fine. The error message will now make it much easier to diagnose (modulo confusion over lint vs. lints).

  24. 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
  25. removed
    awaiting infoRequires more information from the customer to progress
    on Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions