Mobx.dart: Failed build_runner task

Created on 11 Mar 2019  路  5Comments  路  Source: mobxjs/mobx.dart

I'm writing an app that follows a similar paradigm with the todo app, and my codegen has been failing wonderfully. The logs seem unusual as seen below.

flutter packages pub run build_runner build

[INFO] Generating build script...
[INFO] Generating build script completed, took 664ms

[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 10.5s

[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
[SEVERE] file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/atom.dart:47:38: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<Derivation>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'. - 'Derivation' is from 'package:mobx/src/core.dart' ('file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core.dart').Try changing the type of the left hand side, or casting the right hand side to 'Set<Derivation>'.  final Set<Derivation> _observers = {};                                     ^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/atom.dart:103:41: Error: The method 'add' isn't defined for the class 'Map<dynamic, dynamic>'. - 'Map' is from 'dart:core'.Try correcting the name to the name of an existing method, or defining a method named 'add'.      _observationListeners[kind] = {}..add(fn);                                        ^^^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/atom.dart:103:37: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<dynamic Function()>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'.Try changing the type of the left hand side, or casting the right hand side to 'Set<dynamic Function()>'.      _observationListeners[kind] = {}..add(fn);                                    ^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/computed.dart:45:28: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<Atom>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'. - 'Atom' is from 'package:mobx/src/core.dart' ('file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core.dart').Try changing the type of the left hand side, or casting the right hand side to 'Set<Atom>'.  Set<Atom> _observables = {};                           ^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/context.dart:62:60: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<void Function(Object, Reaction)>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'. - 'Object' is from 'dart:core'. - 'Reaction' is from 'package:mobx/src/core.dart' ('file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core.dart').Try changing the type of the left hand side, or casting the right hand side to 'Set<void Function(Object, Reaction)>'.  final Set<ReactionErrorHandler> _reactionErrorHandlers = {};                                                           ^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/context.dart:161:34: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<Atom>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'. - 'Atom' is from 'package:mobx/src/core.dart' ('file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core.dart').Try changing the type of the left hand side, or casting the right hand side to 'Set<Atom>'.    derivation._newObservables = {};                                 ^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/context.dart:236:27: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<Atom>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'. - 'Atom' is from 'package:mobx/src/core.dart' ('file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core.dart').Try changing the type of the left hand side, or casting the right hand side to 'Set<Atom>'.      .._newObservables = {}; // No need for newObservables beyond this point                          ^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/context.dart:332:31: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<Atom>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'. - 'Atom' is from 'package:mobx/src/core.dart' ('file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core.dart').Try changing the type of the left hand side, or casting the right hand side to 'Set<Atom>'.    derivation._observables = {};                              ^file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core/reaction.dart:35:28: Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'Set<Atom>'. - 'Map' is from 'dart:core'. - 'Set' is from 'dart:core'. - 'Atom' is from 'package:mobx/src/core.dart' ('file:///C:/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mobx-0.1.1/lib/src/core.dart').Try changing the type of the left hand side, or casting the right hand side to 'Set<Atom>'.  Set<Atom> _observables = {};                           ^
pub finished with exit code 78

and below is the part of my pubspec where I defined the build_runner and mobx_codegen package.

dev_dependencies:
  build_runner: ^1.2.8
  flutter_test:
    sdk: flutter
  mobx_codegen: ^0.1.0+1

@pavanpodila any help??

Edit: On removing mobx_codegen dev_dependency, build_runner runs successfully but with no outputs.

Most helpful comment

Can you try the following commands:

flutter packages pub run build_runner clean
flutter packages pub run build_runner build --delete-conflicting-outputs

All 5 comments

Can you try the following commands:

flutter packages pub run build_runner clean
flutter packages pub run build_runner build --delete-conflicting-outputs

Thanks @pavanpodila. Unfortunately, trying both commands didn't resolve the issue. Let me try with an older version of mobx codegen if it'll yield something better

https://github.com/dart-lang/dart_style/issues/763

@pavanpodila, I found the issue above which made me try changing versions of mobx itself. So, I enforced my mobx version to be 0.1.0 and the code generation tasks are now working but with no output yet.

It's safe to keep this issue open since I'm still unable to generate a '.g.dart' file

The lack of output after resolving to version 0.1.0 is on me. I'm closing this issue but it would be great to see the versioning problems resolved soonest @pavanpodila.

Thanks @thedejifab. I'll open a separate issue on version hunting in the tool chain.

Was this page helpful?
0 / 5 - 0 ratings