Skip to content
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 in the parent directory could not be loaded #5

Closed
mj-hd opened this issue Jan 19, 2022 · 1 comment · Fixed by #6
Closed

analysis_options.yaml in the parent directory could not be loaded #5

mj-hd opened this issue Jan 19, 2022 · 1 comment · Fixed by #6

Comments

@mj-hd
Copy link

mj-hd commented Jan 19, 2022

The plugin failed to start by following error:

Failed to load options:: Exception:: Not found import_analysis_options.yaml file at the root of your project.
 FileSystemException:: Cannot open file, path = '/Users/mjhd/Projects/project_root/packages/package1/analysis_options.yaml' (OS Error:: No such file or directory, errno = 2)

#0 new Rules.fromOptionsFile (package::import_lint/src/import_lint_options.dart::58::7)
#1     new ImportLintOptions.init

CLI also fails to start by the same error.

My project structure looks like:

- Project Root
  - analysis_options.yaml
  - packages/
    - package1/ (current context root)
      - lib/...
      - pubspec.yaml
    - package2/
      - lib/...
      - pubspec.yaml

Dart Analyzer can read an options file in a parent directory of the target package's root.

If the analyzer can’t find an analysis options file at the package root, it walks up the directory tree, looking for one. If no file is available, the analyzer defaults to standard checks.

https://dart.dev/guides/language/analysis-options#the-analysis-options-file

To support this behavior, context?.contextRoot.optionsFile should be used to load the options file.

similar code in dart-code-metrics: https://github.com/dart-code-checker/dart-code-metrics/blob/7d8269b420d7b40562b72149f92949b288cf40f1/lib/src/analyzer_plugin/analyzer_plugin.dart#L236


Thank you for creating this useful package, I will use this in my project!

@kawa1214
Copy link
Owner

kawa1214 commented Jan 19, 2022

@mj-hd
Thak you for the error report and solution!

I understand the analysis options file specification.
I will fix this error.

@kawa1214 kawa1214 mentioned this issue Feb 6, 2022
kawa1214 added a commit that referenced this issue Feb 6, 2022
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 a pull request may close this issue.

2 participants