dart-lang / pana

Package ANAlysis for Dart
https://pub.dev/packages/pana
BSD 3-Clause "New" or "Revised" License
207 stars 44 forks source link

Pana crashes when package:lints is not found locally. #1236

Closed Skycoder42 closed 1 year ago

Skycoder42 commented 1 year ago

I believe this happens due to the recent changes in lib/src/analysis_options.dart.

If the resource in Line 72 cannot be loaded, it is null. Line 74 then throws an Error (not an Exception!) which is not caught by line 77. Fix should be easy: Simply catch Errors and exceptions, or check if the resource is null.

Logs:

WARNING    Flutter SDK path was not specified, pana will use the default Dart SDK to run `dart analyze` on Flutter packages.
INFO       Running `/opt/hostedtoolcache/dart/3.0.5/x64/bin/dart --version`...
INFO       Running `flutter --no-version-check --version --machine`...
WARNING    Unable to detect Flutter version.
           ProcessException: No such file or directory
             Command: flutter --no-version-check --version --machine
WARNING    pana might update or modify files in `.`.
           Analysis will begin in 15 seconds, hit CTRL+C to abort it.
           To remove this message, use `--no-warning`.
INFO       Running `git rev-parse --show-toplevel`...
INFO       Running `/opt/hostedtoolcache/dart/3.0.5/x64/bin/dart pub get --no-example`...
INFO       Running `/opt/hostedtoolcache/dart/3.0.5/x64/bin/dart pub outdated --json --up-to-date --no-dev-dependencies --no-dependency-overrides`...
INFO       Analyzing package...
SHOUT      Problem analyzing .
           Null check operator used on a null value
           #0      _getLintsCoreAnalysisOptions (package:pana/src/analysis_options.dart:74:39)
           <asynchronous suspension>
           #1      getDefaultAnalysisOptionsYaml (package:pana/src/analysis_options.dart:29:12)
           <asynchronous suspension>
           #2      ToolEnvironment.runAnalyzer (package:pana/src/sdk_env.dart:1[8](https://github.com/Skycoder42/dart_test_tools/actions/runs/5352836295/jobs/9708217294#step:15:9)7:[9](https://github.com/Skycoder42/dart_test_tools/actions/runs/5352836295/jobs/9708217294#step:15:10))
           <asynchronous suspension>
           #3      PackageContext._staticAnalysis (package:pana/src/package_context.dart:190:22)
           <asynchronous suspension>
           #4      PackageContext.staticAnalysis (package:pana/src/package_context.dart:175:23)
           <asynchronous suspension>
           #5      PackageAnalyzer._inspect (package:pana/src/package_analyzer.dart:231:27)
           <asynchronous suspension>
           #6      PackageAnalyzer.inspectDir.<anonymous closure> (package:pana/src/package_analyzer.dart:146:14)
           <asynchronous suspension>
           #7      withTempDir (package:pana/src/utils.dart:236:[12](https://github.com/Skycoder42/dart_test_tools/actions/runs/5352836295/jobs/9708217294#step:15:13))
           <asynchronous suspension>
           #8      main (file:///home/runner/.pub-cache/hosted/pub.dev/pana-0.21.33/bin/pana.dart:[17](https://github.com/Skycoder42/dart_test_tools/actions/runs/5352836295/jobs/9708217294#step:15:18)6:[19](https://github.com/Skycoder42/dart_test_tools/actions/runs/5352836295/jobs/9708217294#step:15:20))
           <asynchronous suspension>
Error: Process completed with exit code 1.
marandaneto commented 1 year ago

Same issue.

Skycoder42 commented 1 year ago

I am using pana as global tool - maybe that is relevant as well? Because I do not know if the fact that it's a compiled binary changes how the Isolate.resolvePackageUri works.

isoos commented 1 year ago

Thanks for reporting! A fix is pending for this issue #1235.

isoos commented 1 year ago

Please try to upgrade pana, I think it should work now.

Skycoder42 commented 1 year ago

Yes, this fixed the problem, thank you