Build: NoSuchMethodError: The getter 'inputs' was called on null.

Created on 31 Aug 2018  Â·  32Comments  Â·  Source: dart-lang/build

I get this message :

You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues

so, my build environment:

  • [2.0.0-edge.be6309690fd60284a87f3258a740c7c30efb1092 ] Dart SDK Version (dart --version)

  • [build_runner ^0.10.0 ] What package(s) from this repo you are using, and the version (i.e. build_runner 0.7.12)

  • [Just demo at https://flutter.io/json/ ] What builder(s) you are using (or writing yourself). Try to give a short summary of what they do.

  • [ MacOS] Whether you are using Windows, MacOSX, or Linux (if applicable)

  • [ iOS Simulator] Whether you are using Chrome, Safari, Firefox, Edge (if applicable)

  • [dependencies:
    cupertino_icons: ^0.1.2
    transparent_image: ^0.1.0
    pull_to_refresh: ^1.1.5
    json_annotation: ^1.0.0

dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^0.10.0
json_serializable: ^1.0.0
] Any other packages or constraints we should know about

error message:

NoSuchMethodError: The getter 'inputs' was called on null.
Receiver: null
Tried calling: inputs
dart:core Object.noSuchMethod
/Users/zhangxianqiangmacbook/.pub-cache/hosted/pub.flutter-io.cn/build_runner_core-0.3.1+5/lib/src/asset_graph/serialization.dart 58:20 _AssetGraphDeserializer.deserialize
package:build_runner_core/src/asset_graph/graph.dart 42:48 new AssetGraph.deserialize
package:build_runner_core/src/generate/build_definition.dart 209:38 _Loader._tryReadCachedAssetGraph.
package:build_runner_core/src/logging/logging.dart 25:30 logTimedAsync
package:build_runner_core/src/generate/build_definition.dart 207:12 _Loader._tryReadCachedAssetGraph
package:build_runner_core/src/generate/build_definition.dart 79:28 _Loader.prepareWorkspace
package:build_runner_core/src/generate/build_definition.dart 64:50 BuildDefinition.prepareWorkspace
package:build_runner_core/src/generate/build_impl.dart 106:49 BuildImpl.create
package:build_runner_core/src/generate/build_runner.dart 31:37 BuildRunner.create
package:build_runner/src/generate/build.dart 105:35 build
package:build_runner/src/entrypoint/build.dart 28:24 BuildCommand.run
package:args/command_runner.dart 194:27 CommandRunner.runCommand
package:args/command_runner.dart 109:29 CommandRunner.run.
dart:async new Future.sync
package:args/command_runner.dart 109:11 CommandRunner.run
package:build_runner/src/entrypoint/run.dart 22:31 run
.dart_tool/build/entrypoint/build.dart 18:22 main

pub finished with exit code 1

build_runner_core needs info bug

Most helpful comment

Try run flutter packages pub run build_runner build with --delete-conflicting-outputs an see if it works. For me that was the solution!

All 32 comments

Thanks for the report, if you are still experiencing this issue could you attach your asset graph file to this bug (or you can email it if you prefer - it contains relative paths and content hash information for your project). The file can be found at .dart_tool/build/<some-hash>/asset_graph.json.

I met the same issue

@qiang437587687 @jakemac53 I deleted the /.dart_tool , then everything is okay

Unfortunately without a repro or asset graph we can't make much progress here. If somebody else runs into this please attach an asset graph as described above (or even better if you can create a minimal repro then provide those instructions).

I've hit this a few times I believe. Usually, I see no information and just [SEVERE] Failed after 1.2s. One time, I received OP's error. I have this happen 80% of the time if I rename a component that's referenced as a template in my routing file. For example, if I have a component called hero_component which I reference in a routing file as import 'hero_component.template.dart' as hero_component which I rename to superhero_component, I can produce the [SEVERE] build error. The renamed component is only referenced in the routes.dart file via a .template.

I believe it has to do with some interaction with my IDE (intellij) saving the file midway through a rename, which causes bad template files to be generated. If I have a successful build, I can shut off webdev, do my renames, and restart webdev, I usually have success. If I've already received a build failure, there is no recovery beyond doing a git checkout ..

Here is my asset_graph.json: https://gist.github.com/psylinse/9620f62ff16e4b6713011315c4c71dbd

Removing .dart_tool caused it to fail in without information again.


Compiled 12,669,913 characters Dart to 1,350,745 characters JavaScript in 9.67 seconds
Dart file (web/main.dart) compiled to JavaScript: web/main.dart.js

[INFO] Heartbeat:35.2s elapsed, 9983/9984 actions completed.
[INFO] Build:Running build completed, took 35.4s

[INFO] Build:Caching finalized dependency graph...
[INFO] Build:Caching finalized dependency graph completed, took 297ms

[SEVERE] Build:
Failed after 35.7s

Info:

  • AngularDart app, pubspec:
name: redacted
description: redacted

environment:
  sdk: '>=2.0.0 <3.0.0'

dependencies:
  angular: ^5.0.0
  angular_forms: ^2.0.0
  angular_components: ^0.9.1
  angular_router: ^2.0.0-alpha+19
  http: ^0.11.0
  stream_transform: ^0.0.6

dev_dependencies:
  angular_test: ^2.0.0
  build_runner: ^0.10.0
  build_test: ^0.10.2
  build_web_compilers: ^0.4.0
  test: ^1.0.0
  • build.yaml:
targets:
  $default:
    builders:
      angular_components|scss_builder:
        enabled: True
  • macOS
  • dart --version: Dart VM version: 2.0.0 (Fri Aug 3 10:53:23 2018 +0200) on "macos_x64"

Interesting, I think I figured out what part of my code is triggering the build failure and these errors. If I do a rename of the component dart, html, and scss file, but forget to rename the templateUrl and styleUrl portions of the Component declaration, fails in this way. For example, from the example above, I forgot to rename the referenced html and scss files inside of hero_component.dart:

These lines:

  templateUrl: 'hero_component.html',
  styleUrls: ['hero_component.scss.css'],

should be:

  templateUrl: 'superhero_component.html',
  styleUrls: ['superhero_component.scss.css'],

After renaming, the build was still failing but after I deleted .dart_tools it compiles correctly. Does all of this make sense? If not, I can probably put together a repo that replicates the issue.

@jakemac53 I have saved my asset_graph.json when encountering the bug. Where can I email it to?

Deleting .dart_tool worked for me aswell to solve the build bug

@anondev32 you can email me [email protected]

delete Progect->ProjectName->.dart_tool解决。一般是缓存导致的。

delete Progect->ProjectName->.dart_tool解决。一般是缓存导致的。

nice

Try run flutter packages pub run build_runner build with --delete-conflicting-outputs an see if it works. For me that was the solution!

Here is the assets_graph.json file you asked for. I hope it helps clue you in to the actual issue.

asset_graph.zip

Just hit this bug. Removing ./dart_tool does resolve the build failing, but this makes Dart feel unstable to developers building serious software.

I hope the team is now devoting more resources to fixing bugs / rewriting buggy parts rather than creating new features.

As soon as we have more information we will continue to investigate.

We will now automatically recover from this scenario at least, and log a bit more information which should help track it down in the future.

[INFO] Generating build script completed, took 291ms
[INFO] Watch:Setting up file watchers...
[INFO] Watch:Setting up file watchers completed, took 11ms

[INFO] Watch:Waiting for all file watchers to be ready...
[INFO] Watch:Waiting for all file watchers to be ready completed, took 204ms

[INFO] BuildDefinition:Initializing inputs
[INFO] BuildDefinition:Reading cached asset graph...
[INFO] BuildDefinition:Reading cached asset graph completed, took 222ms

[INFO] BuildDefinition:Checking for updates since last build...
[INFO] BuildDefinition:Checking for updates since last build completed, took 622ms

[INFO] Build:Running build...
[INFO] Build:Running build completed, took 208ms

[INFO] Build:Caching finalized dependency graph...
[SEVERE] build.fallback:
The results field in qr|glob.665.KioubW9kdWxlLmxpYnJhcnk= references a non-existent asset null and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.
[SEVERE] build.fallback:
The results field in qr|glob.665.KioubW9kdWxlLmxpYnJhcnk= references a non-existent asset null and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.
[SEVERE] build.fallback:
The results field in qr|glob.665.KioubW9kdWxlLmxpYnJhcnk= references a non-existent asset null and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.
[SEVERE] build.fallback:
The results field in qr|glob.665.KioubW9kdWxlLmxpYnJhcnk= references a non-existent asset null and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.
[INFO] Build:Caching finalized dependency graph completed, took 133ms

[INFO] Build:Succeeded after 349ms with 0 outputs (0 actions)

Serving `test` on http://localhost:8080
Serving `example` on http://localhost:8081

😕

I am going to go ahead and close this issue, as I haven't seen further reports since the fix.

If somebody does hit this again please comment here and we can re-open it, or you can open a new issue.

Hello.

[INFO] Running build completed, took 13.5s
[SEVERE] The outputs field in incognita|lib/geofencing/android_geofencing_settings.g.dart references a non-existent asset incognita|lib/geofencing/android_geofence_settings.built_value.g.part and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.

The latest log indicates a different issue it looks like so re-opening. It looks like there is a scenario where we aren't properly cleaning up the outputs of a generated node.

Hey! Same here:

[SEVERE] The outputs field in borrelly_project|lib/database/database.g.dart references a non-existent asset borrelly_pro
ject|lib/database/app_database.floor.g.part and will corrupt the asset graph. If you encounter this error please copy th
e details from this message and add them to https://github.com/dart-lang/build/issues/1804.

@TechnologicznaSowa @sanekyy do either of you know how you got in this state, or even better can you give me some reproduction steps that will cause it?

@jakemac53 I believe that in my case it was the file name change

Capturing some offline discussion:

There is something interesting here about how the .g.dart file is an output for a later phase than .anything.g.part. In one of the cases reported here the .g.part would be an _input_ to the .g.dart, and also appears to be tracked as an output.

There might be something going on with cycles between nodes or something like that. When we recursively remove nodes from dropped source files we might be missing something.
Or maybe there is some bug where the 2 ways output/input references are incomplete.

It's possible we need to do something different when we end up with an output link from a file that is unreadable due to phase ordering - as differentiated from unreadable due to not being output, or not existing (and becoming a placeholder node). Hopefully this isn't the case and we can focus most closely on the node removal code paths.

Just got the following, if it's of any help:
[INFO] Caching finalized dependency graph...
[SEVERE] The outputs field in parents|lib/stores/message_recipient/message_recipient_store.g.dart references a non-existent asset parents|lib/stores/message_recipient/message_recipient.json_serializable.g.part and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.
[SEVERE] The outputs field in parents|lib/stores/message_recipient/message_recipient_store.g.dart references a non-existent asset parents|lib/stores/message_recipient/message_recipient.store_generator.g.part and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.
[INFO] Caching finalized dependency graph completed, took 148ms

After running a second time:
[INFO] Reading cached asset graph...
[SEVERE] Found a null output from parents|lib/stores/message_recipient/message_recipient_store.g.dart which is a GeneratedAssetNode. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.
[WARNING] Throwing away cached asset graph due to version mismatch or corrupted asset graph.
[INFO] Reading cached asset graph completed, took 204ms

And everything seems to have been built fine.

Thanks for the report @nelson-uruworks . Do you remember what actions you had taken right before you encountered these errors by chance?

I think was creating the store with some properties of a class I was changing, renaming and moving the files to a different path. That class has the annotation @JsonSerializable(explicitToJson: true) which also needs it's .g.dart part to get built, so maybe it's a chain of events, but I'm not sure

Thanks - I think we did have a bug when moving files previously and its possible there is still something going on there. Can you confirm your versions of build_runner and build_runner_core (you can see them by running pub deps or looking in your pubspec.lock file).

Got this error after renaming a file:
[SEVERE] The outputs field in reddiyo|lib/models/plan_goal_model.g.dart references a non-existent asset reddiyo|lib/models/goal_model.json_serializable.g.part and will corrupt the asset graph.

build_runner: 1.7.4
build_runner_core: 4.3.0

Same here, got this error after renaming a file:

[SEVERE] The outputs field in Timereporter|lib/defaultSettingsForm.g.dart references a non-existent asset Timereporter|lib/normalTimeForm.functional_widget.g.part and will corrupt the asset graph.

build_runner: 1.10.0
build_runner_core: 5.2.0

However, everything seems to work fine.

Got this error today, after renaming appUser to AppUser and back. Any suggestions on how to fix this?

This is causing a problem in my code base where, I have to name the file AppUser.dart instead of appUser.dart

The outputs field in weight_loss_coach|lib/models/appUser.g.dart references a non-existent asset weight_loss_coach|lib/models/AppUser.json_serializable.g.part and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804. [INFO] Caching finalized dependency graph completed, took 97ms

Ok, I was able to repro this actually now, specifically I did the following:

  • Open up the json_serializable example app, and the lib/example.dart file
  • Run pub run build_runner watch
  • Update the part statement to part 'Example.g.dart';
  • Rename the file to Example.dart, gives this error:
[SEVERE] The outputs field in example|lib/Example.g.dart references a non-existent asset example|lib/example.json_serializable.g.part and will corrupt the asset graph. If you encounter this error please copy the details from this message and add them to https://github.com/dart-lang/build/issues/1804.

I think the issue here is somehow caused by renaming a file which has an invalid part statement in it, which then becomes valid after the rename.

Ok, I was finally able to make a repro for this and added a test in https://github.com/dart-lang/build/pull/2845, where I can follow up with a fix once I have one.

OK, this issue should be resolved now in version 6.0.3 of build_runner_core 🥳

Was this page helpful?
0 / 5 - 0 ratings