Closed kuhnroyal closed 12 months ago
Does running the build with --verbose
print a stack trace?
The file uploads table does NOT use the
local_date_converter.dart
and does not import it, same goes for thecatalog_entity.dart
file. In any case the FK linked foo table has these imports and that is likely why they are transitively (mistakenly?) get added.
We also add imports for Dart files transitively imported through other .drift
files. This is since drift files don't have a real module system - tables defined in a transitively imported file are reachable and for consistency, we try to emulate this for Dart imports in drift files as well. I think this hasn't changed recently.
Did the drift file actually importing the Dart file also see this error?
I got 2 stacks with analyzer 6.2.0:
#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:243:67)
#1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:270:20)
#2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:1841:22)
#3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1266:7)
#4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2217:18)
<asynchronous suspension>
package:analyzer/src/summary2/linked_element_factory.dart 130:7 LinkedElementFactory.createLibraryElementForReading
package:analyzer/src/summary2/linked_element_factory.dart 194:14 LinkedElementFactory.elementOfReference
package:analyzer/src/summary2/linked_element_factory.dart 222:12 LinkedElementFactory.libraryOfUri
package:analyzer/src/summary2/linked_element_factory.dart 226:19 LinkedElementFactory.libraryOfUri2
package:analyzer/src/summary2/bundle_reader.dart 1783:28 ResolutionReader.libraryOfUri
package:analyzer/src/summary2/bundle_reader.dart 483:30 LibraryElementLinkedData._readLibraryOrAugmentation
package:analyzer/src/summary2/bundle_reader.dart 457:5 LibraryElementLinkedData._read
package:analyzer/src/summary2/bundle_reader.dart 220:5 ElementLinkedData.read
package:analyzer/src/summary2/bundle_reader.dart 446:13 LibraryElementLinkedData.read
package:analyzer/src/dart/element/element.dart 4476:17 LibraryElementImpl._readLinkedData
package:analyzer/src/dart/element/element.dart 4223:5 LibraryElementImpl.libraryExports
package:analyzer/src/dart/element/element.dart 4661:12 LibraryOrAugmentationElementImpl.children
package:analyzer/src/dart/element/element.dart 4084:18 LibraryElementImpl.children
package:analyzer/src/dart/element/element.dart 2433:27 ElementImpl.visitChildren
package:analyzer/dart/element/visitor.dart 309:13 RecursiveElementVisitor.visitLibraryElement
package:drift_dev/src/analysis/resolver/discover.dart 185:5 _FindDartElements.find
package:drift_dev/src/analysis/resolver/discover.dart 78:22 DiscoverStep.discover
package:drift_dev/src/analysis/driver/driver.dart 129:7 DriftAnalysisDriver.discoverIfNecessary
package:drift_dev/src/analysis/driver/driver.dart 166:7 DriftAnalysisDriver.findLocalElements
package:drift_dev/src/backends/build/drift_builder.dart 226:21 _DriftBuildRun._checkForElementsToBuild
package:drift_dev/src/backends/build/drift_builder.dart 149:10 _DriftBuildRun.run
package:drift_dev/src/backends/build/drift_builder.dart 106:5 DriftBuilder.build
Did the drift file actually importing the Dart file also see this error?
Hard to say, there is always only one or 2 errors in the output but it is not deterministic for which tables.
It seems the analyzer is calling removeLibraries
with the converters as arguments (among a long list of other libraries).
[removeLibraries][uriSet: {package:foo_app/db/converter/built_value_enum_converter.dart, package:foo_app/db/converter/local_date_converter.dart, ...
This time it also failed for the built_value_enum_converter.dart
which is directly used...
@simolus3 I sent you a mail with the full log.
If I run the generation often enough without cleaning, at some point it seems to succeed...
Ok, so I just saw that there was a change in drift_dev: 2.11.2
to follow exports. This seems to be the culprit.
I reverted to my 2.11.1
state and just updated to drift_dev:2.11.2
and the errors start happening.
Did this happen with analyzer: 6.3.0
as well or was there a version conflict preventing that? Just wondering because some code in summary2/linked_element_factory.dart
seems to have changed recently judging on the line numbers in the stack trace. Drift might have uncovered this, but it still looks like a problem with the analyzer or build_resolvers
package.
Did this happen with
analyzer: 6.3.0
as well or was there a version conflict preventing that? Just wondering because some code insummary2/linked_element_factory.dart
seems to have changed recently judging on the line numbers in the stack trace. Drift might have uncovered this, but it still looks like a problem with the analyzer orbuild_resolvers
package.
This is probably not related to analyzer 6 - see my previous comment.
The error starts to happen with drft_dev: 2.11.2
independent of the analyzer.
I am trying to migrate from drift 2.11.1 + analyzer:5.12.0 to drift 2.12.1 + analyzer:6.1.0/6.2.0. With drift 2.11.1 everything works perfectly but after upgrades I get errors when trying to generate.
A stripped down version of the file upload table file:
The content of the
file_upload_table.expr.temp.dart
:Here is what I think is happening, but I might be way off:
The file uploads table does NOT use the
local_date_converter.dart
and does not import it, same goes for thecatalog_entity.dart
file. Still thelocal_date_converter.dart
andcatalog_entity.dart
end up as imports in thefile_upload_table.expr.temp.dart
file and then for whatever reason can not be found. Either the imports are added incorrectly in 2.12 or something might have changed in the analyzer that now "optimizes" the libraries away.In any case the FK linked foo table has these imports and that is likely why they are transitively (mistakenly?) get added.