I'm getting this error when trying to build an app with flutter pub run build_runner build --delete-conflicting-outputs.
I tried the following commands multiple times, but that did not help.
flutter clean
flutter pub get
flutter pub run build_runner clean
My dao's get generated (.moor-files, because I am using a build config to be compatible with code generated from MobX generator), but my tables aren't.
This is my build config:
targets:
$default:
builders:
moor_generator:
enabled: false
moor_generator|moor_generator_not_shared:
enabled: true
# Run built_value_generator when moor is done, which is not in this target.
mobx_codegen|mobx_generator:
enabled: false
# all other builders that need to work on moor classes should be disabled here
# as well
run_mobx:
dependencies: ['hello_nwyrk']
builders:
# Disable moor builders. By default, those would run on each target
moor_generator:
enabled: false
moor_generator|preparing_builder:
enabled: false
# we don't need to disable moor_generator_not_shared, because it's disabled by default
And this is the error that gets thrown when I run with the --verbose option:
[SEVERE] moor_generator:moor_generator_not_shared on lib/data/moor/tables/metros.dart (cached):
InconsistentAnalysisException: Requested result might be inconsistent with previously returned results
package:analyzer/src/dart/analysis/session.dart 146:7 AnalysisSessionImpl._checkConsistency
package:analyzer/src/dart/analysis/session.dart 113:5 AnalysisSessionImpl.getResolvedLibraryByElement
package:moor_generator/src/backends/build/build_backend.dart 95:41 BuildBackendTask.loadElementDeclaration
package:moor_generator/src/analyzer/dart/parser.dart 64:30 MoorDartParser.loadElementDeclaration
package:moor_generator/src/analyzer/dart/table_parser.dart 150:35 TableParser._parseColumns.<fn>
dart:async Future.wait
package:moor_generator/src/analyzer/dart/table_parser.dart 149:34 TableParser._parseColumns
package:moor_generator/src/analyzer/dart/table_parser.dart 13:28 TableParser.parseTable
package:moor_generator/src/analyzer/dart/parser.dart 34:25 MoorDartParser.parseTable
package:moor_generator/src/analyzer/runner/steps/parse_dart.dart 59:34 ParseDartStep._parseTable
package:moor_generator/src/analyzer/runner/steps/parse_dart.dart 33:15 ParseDartStep.parse
package:moor_generator/src/analyzer/runner/task.dart 126:35 Task._parse
package:moor_generator/src/analyzer/runner/task.dart 41:26 Task.runTask
package:moor_generator/src/backends/build/moor_builder.dart 36:18 MoorBuilder.analyzeDartFile
package:moor_generator/src/backends/build/generators/dao_generator.dart 13:34 DaoGenerator.generate
package:source_gen/src/builder.dart 322:33 _generate
package:source_gen/src/builder.dart 83:15 _Builder._generateForLibrary
package:source_gen/src/builder.dart 75:11 _Builder.build
package:build runBuilder
package:build_runner_core/src/generate/build_impl.dart 527:19 _SingleBuild._runForInput.<fn>.<fn>.<fn>
package:build_runner_core/src/generate/performance_tracker.dart 302:15 _NoOpBuilderActionTracker.trackStage
package:build_runner_core/src/generate/build_impl.dart 525:23 _SingleBuild._runForInput.<fn>.<fn>
package:build_runner_core/src/generate/build_impl.dart _SingleBuild._runForInput.<fn>.<fn>
package:timing/src/timing.dart 222:44 NoOpTimeTracker.track
package:build_runner_core/src/generate/build_impl.dart 475:22 _SingleBuild._runForInput.<fn>
package:pool/pool.dart 127:28 Pool.withResource
package:build_runner_core/src/generate/build_impl.dart 471:17 _SingleBuild._runForInput
package:build_runner_core/src/generate/build_impl.dart 409:38 _SingleBuild._runBuilder.<fn>
dart:async Future.wait
package:build_runner_core/src/generate/build_impl.dart 408:36 _SingleBuild._runBuilder
package:build_runner_core/src/generate/build_impl.dart 347:20 _SingleBuild._runPhases.<fn>.<fn>
dart:async _completeOnAsyncReturn
package:build_runner_core/src/generate/build_impl.dart _SingleBuild._matchingPrimaryInputs
[SEVERE] Build:
Failed after 135ms
[+2846 ms] "flutter run" took 2,877ms.
[ +7 ms] pub finished with exit code 1
[ +1 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1 _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:375:7)
<asynchronous suspension>
#2 PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:260:15)
#3 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:977:18)
#4 _rootRunUnary (dart:async/zone.dart:1198:47)
#5 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#8 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#9 Future._completeWithValue (dart:async/future_impl.dart:529:5)
#10 Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#11 _rootRun (dart:async/zone.dart:1190:13)
#12 _CustomZone.run (dart:async/zone.dart:1093:19)
#13 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#14 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#15 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#17 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#18 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
[ +58 ms] ensureAnalyticsSent: 57ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 1
Flutter version
Flutter 1.22.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1aafb3a8b9 (3 weeks ago) • 2020-11-13 09:59:28 -0800
Engine • revision 2c956a31c0
Tools • Dart 2.10.4
Any help would be appreciated!
Thanks for the report! Unfortunately those issues can't really be fixed, we just need to invoke the analyzer multiple times and hope that we don't get an InconsistentAnalysisException. The exception you got indicates that one case was missing, I changed that to retry 5 times.
Does adding this to your pubspec fix the problem?
dependency_overrides:
moor_generator:
git:
url: https://github.com/simolus3/moor.git
ref: develop
path: moor_generator
Thanks for your quick answer!
I tried that; but that gave me this error:
Because every version of moor_generator from git depends on moor ^3.5.0-dev which doesn't match any versions, moor_generator from git is forbidden.
So, because hello_nwyrk depends on moor_generator from git, version solving failed.
So I tried adding this to the dependency overrides.
moor:
git:
url: https://github.com/simolus3/moor.git
ref: develop
path: moor
Which gave me even more errors:
Because every version of moor from git depends on sqlite3 ^0.1.9-nullsafety and no versions of sqlite3 match >=0.1.9-nullsafety <0.1.9-nullsafety.0, every version of moor from git requires sqlite3 ^0.1.9-nullsafety.0.
And because sqlite3 >=0.1.9-nullsafety.0 depends on ffi ^0.2.0-nullsafety and every version of path_provider_windows depends on ffi ^0.1.3, moor from git is incompatible with path_provider_windows.
And because path_provider 1.6.24 depends on path_provider_windows ^0.0.4 and no versions of path_provider match >1.6.24 <2.0.0, moor from git is incompatible with path_provider ^1.6.24.
So, because hello_nwyrk depends on both path_provider ^1.6.24 and moor from git, version solving failed.
I did try with the dev version of sqlite3, but than the path_provider_windows kept complaining (no idea where that comes from.) Any ideas on how to resolve this?
Oh no, it looks like releasing the null safe version on develop will be a pain...
In the meantime, I cherry-picked the fix to the workaround-analyzer-issue branch. Can you try that one? You can remove the other dependency overrides, moor_generator on that branch should work with the current moor version.
Thanks! Well, that kind of works: running flutter pub get only shows a warning about the use of an overridden depencency now but runs fine.
The build on the other hand, failed three times (even after another flutter clean & flutter pub get) but than completed on the fourth run. Don't know if this actually solves anything.
Oh :( With the same InconsistentAnalysisException?
Yes, indeed.
Yes, I am having this issue when I run flutter pub run build_runner build --delete-conflicting-outputs. I wanted to add new table to my existing app.
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.10.0
moor_generator: ^3.3.1

@fooshyangsong Do you use other generators too? Can you tell me the exact versions of moor_generator, analyzer and build_resolvers you're using? You can find them in pubspec.lock
@fooshyangsong If you should get stuck, I "solved" this by reverting to an older Flutter version (1.18 in my case)
I didn't use other generator
moor_generator:
dependency: "direct dev"
description:
name: moor_generator
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.40.6"
analyzer_plugin_fork:
dependency: transitive
description:
name: analyzer_plugin_fork
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.3"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.4"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.3"
Apologies for the delay on this. There are new apis in the build package that assist with loading ast nodes, I migrated the generator to use them. As far as I understand, that should resolve the inconsistent analysis exceptions. If the dependency conflicts aren't too bad, can you try using moor_generator from the referenced commit?
Hi,
I'm having the same issue since I added some new DAOs. Tried to clean it multiple times but nothing worked and I'm totally stucked since I cant use my database now.
moor_ffi: ^3.4.0
moor_ffi: ^0.8.0
path: ^1.7.0
path_provider: ^1.6.24
moor_generator: ^3.4.0
build_runner: ^1.10.11
Flutter 1.22.5
"InconsistentAnalysisException: Requested result might be inconsistent with previously returned results"
@simolus3 how can I reference the commit from moor_generator in my pubspec.yaml?
You could try this:
dependency_overrides:
moor:
git:
url: https://github.com/simolus3/moor.git
ref: develop
path: moor
sqlparser:
git:
url: https://github.com/simolus3/moor.git
ref: develop
path: sqlparser
Let me know if pub complains about that, I can try to fix dependency conflicts.
@simolus3 I tried to fix my issue once in the morning by adding each dao seperately and afterwords running the build command.
Since I had to change some database fields and regenerate it, I broke everything again. So I tried to use your code above for pubspec. I went through dependency hell with this ^^. I upgraded flutter to beta channel, since Im working on stable channel and then it complained about almost every dependency in my project. So I removed the version for each one, to retrieve the best fitting version automatically but I couldnt make it work.
I'll try to rebuild everything again with my approach before updating and will report if it works.
Because every version of moor from git depends on meta ^1.3.0-nullsafety.6 and every version of flutter_test from sdk depends on meta 1.3.0-nullsafety.3, moor from git is incompatible with flutter_test from sdk.
@simolus3 I had tried use the new referenced, but there's issue on meta ^1.3.0-nullsafety. What should I do? I am currently in stable version Flutter 1.22.5.
I once again cherry-picked to workaround to the workaround-analyzer-issue branch. With that, you hopefully only need this:
dependency_overrides:
moor_generator:
git:
url: https://github.com/simolus3/moor.git
ref: workaround-analyzer-issue
path: moor_generator
If it works I can publish that fix to pub too.
Thank you @simolus3, it working good.
But before this,I manage to fix this issue by removing all the table and rebuild each table one by one.
@simolus3 works perfectly and saves a ton of time! Before I had to remove every dao, build, add next dao, build again...
@simolus3 works for me, thank you very much. Tell us when the fix is up.
I just released moor_generator version 3.4.1 which contains this fix.
Thanks for this! Will try this soon.
Most helpful comment
I once again cherry-picked to workaround to the
workaround-analyzer-issuebranch. With that, you hopefully only need this:If it works I can publish that fix to pub too.