Sdk: Analyzer gives bogus messages on a clean Flutter dev channel checkout. (re: stale .dart_tool)

Created on 14 Dec 2019  Â·  9Comments  Â·  Source: dart-lang/sdk

I'm seeing a problem in the analyzer in the HEAD on flutter (flutter analyze --flutter-repo). It gives incorrect errors:

  error • The argument type 'BuildContext (where BuildContext is defined in
         /Users/gspencer/code/flutter/packages/flutter/lib/src/widgets/framework
         .dart)' can't be assigned to the parameter type 'BuildContext (where
         BuildContext is defined in
         /Users/gspencer/code/flutter/packages/flutter/lib/src/widgets/framework
         .dart)' • packages/flutter/lib/src/cupertino/theme.dart:450:51 •
         argument_type_not_assignable

When a) the code hasn't changed, and b) it's saying that it can't assign between types, but references the same location twice. There are a lot of these errors, but it's also not just that type. It has a bunch of errors about The argument type 'DiagnosticsProperty' can't be assigned to the parameter type 'DiagnosticsNode', when DiagnosticsProperty directly extends DiagnosticsNode.

Here's a Gist with some (>800) example errors on a "clean" flutter repo on master:
https://gist.github.com/gspencergoog/5d21b7fa6594e8086e15c0bd9b001b14

Originally they went away when I sync'ed back to a flutter (2eed59c1d) that was older than the most recent Dart roll (https://github.com/flutter/engine/pull/14453), but now it happens even at that revision.

I have tried the following:

  • nuking my flutter cache dir
  • nuking ~/.dartServer
  • nuking ~/.pub-cache
  • rebooting my machine, deleting the above again, running git clean -f; git reset --hard.
  • Downloading the latest Flutter dev channel package and unpacking it into a fresh directory. Running a flutter analyze --flutter-repo there resulted in 329,508 errors.
  • had someone else run the analyzer on their repo, and it worked fine for them, and
  • it also works fine on the CI systems, so it's something local with my machine/config.

Between the time it worked, and when it stopped working, I didn't change my config, I just synced to the latest master revision.

I'm kind of running out of things to try...

This is on macOS.

Flutter 1.13.3-pre.23 • channel unknown • unknown source
Framework • revision c06bf6503a (8 hours ago) • 2019-12-13 17:42:35 -0500
Engine • revision e0e0ac0a68
Tools • Dart 2.8.0 (build 2.8.0-dev.0.0 45db297095)
area-analyzer

Most helpful comment

git clean -xffd (which deletes the .dart_tool directories) seems to fix it.

All 9 comments

@scheglov

OK, I tried the following:

  • nuking my flutter cache dir
  • nuking ~/.dartServer
  • nuking ~/.pub-cache

All of which I had done before. Then I did this:

  • deleted ~/Library/Caches/flutter_engine
  • ran git clean -d -x -f

And lo and behold! No analyzer issues now. Yay!

I did save a tar file of my flutter directory before I did the git clean (but after removing the cache). I restored that directory, and now it shows 106 issues.

I then tried removing all of the build directories, and that seemed to fix it too, so I started alternately removing them and running the analyzer, and eventually narrowed down the problem to the directory packages/flutter/.dart_tool/build.

I started narrowing down files in that dir, and if I remove packages/flutter/.dart_tool/build/ec9b995a9d0b4aafe92e2a32b59a3f3c/asset_graph.json, the analyzer errors disappear. I've attached a tarball with just that asset graph. If you sync flutter to flutter/flutter@c06bf6503, you should be able to repro the problem.

broken_build.tar.gz

The curious thing to me is that when I downloaded a fresh zip file from our website (e.g. this dev channel 1.13.2), I got 300K errors, and that asset_graph.json file (or one similar) doesn't exist in that zip file.

I tried unpacking the zip file and removing all the temporary things to reduce it back to a "base" repo, but no matter what I removed, it still gave me the 300K errors. Here's what I tried:

  • nuking flutter/bin/cache
  • nuking flutter/.pub-cache
  • nuking ~/.dartServer
  • nuking ~/.pub-cache
  • ran git clean -d -x -f
  • ran git clean -d -X -f
  • ran git reset --hard

So I downloaded https://storage.googleapis.com/flutter_infra/releases/dev/macos/flutter_macos_v1.13.2-dev.zip, unzipped it, and then executed ./bin/flutter analyze --flutter-repo and got 365K errors. I captured the full log but it was too big for a GitHub comment or even a gist.

[✓] Flutter (Channel dev, v1.13.2, on Mac OS X 10.14.6 18G87, locale en-US)
    • Flutter version 1.13.2 at /Users/fujino/Downloads/flutter 2
    • Framework revision 4944622b5d (4 days ago), 2019-12-12 18:43:58 +0000
    • Engine revision 12bf95fd49
    • Dart version 2.7.0 (build 2.7.0-dev.2.1 8b8894648f)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/fujino/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.2)
    • Xcode at /Users/fujino/Downloads/Xcode-beta.app/Contents/Developer
    • Xcode 11.2, Build version 11B44
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

Does it work if you run flutter update-packages before flutter analyze --flutter-repo?

Yes, it appears to work when I do that...

Seeing the same problem after doing a flutter upgrade on the dev branch.

git clean -xffd (which deletes the .dart_tool directories) seems to fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xster picture xster  Â·  3Comments

DartBot picture DartBot  Â·  3Comments

brooth picture brooth  Â·  3Comments

xster picture xster  Â·  3Comments

Hixie picture Hixie  Â·  3Comments