Open filippo-signorini opened 10 months ago
@scheglov The relevant portion of the log appears to be the following:
[10:42:05 AM] [Analyzer] [Error] Unhandled exception:
Bad state: No library: file:///C:/Users/Filippo/Documents/FlutterApps/ellisse_presenze/lib
#0 LinkedElementFactory.libraryOfUri2 (package:analyzer/src/summary2/linked_element_factory.dart:232:7)
#1 LibraryBuilder._buildImport (package:analyzer/src/summary2/library_builder.dart:670:48)
#2 LibraryBuilder._buildDirectives.<anonymous closure> (package:analyzer/src/summary2/library_builder.dart:559:14)
#3 MappedListIterable.elementAt (dart:_internal/iterable.dart:415:31)
#4 ListIterator.moveNext (dart:_internal/iterable.dart:344:26)
#5 new _List._ofEfficientLengthIterable (dart:core-patch/array.dart:162:27)
#6 new _List.of (dart:core-patch/array.dart:127:20)
#7 new List.of (dart:core-patch/array_patch.dart:49:20)
#8 ListIterable.toList (dart:_internal/iterable.dart:214:7)
#9 IterableExtension.toFixedList (package:analyzer/src/utilities/extensions/collection.dart:10:18)
#10 LibraryBuilder._buildDirectives (package:analyzer/src/summary2/library_builder.dart:563:8)
#11 LibraryBuilder.buildElements (package:analyzer/src/summary2/library_builder.dart:161:5)
#12 Linker._computeLibraryScopes (package:analyzer/src/summary2/link.dart:169:15)
#13 Linker._buildOutlines.<anonymous closure> (package:analyzer/src/summary2/link.dart:124:15)
#14 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:172:29)
#15 Linker._buildOutlines (package:analyzer/src/summary2/link.dart:121:23)
#16 Linker.link (package:analyzer/src/summary2/link.dart:96:11)
#17 link (package:analyzer/src/summary2/link.dart:39:16)
#18 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:180:30)
<asynchronous suspension>
#19 LibraryContext.load.<anonymous closure> (package:analyzer/src/dart/analysis/library_context.dart:246:7)
<asynchronous suspension>
#20 PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14)
<asynchronous suspension>
#21 LibraryContext.load (package:analyzer/src/dart/analysis/library_context.dart:244:5)
<asynchronous suspension>
#22 AnalysisDriver._computeUnitElement.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1508:7)
<asynchronous suspension>
#23 PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14)
<asynchronous suspension>
#24 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1127:22)
<asynchronous suspension>
#25 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2249:7)
<asynchronous suspension>
#0 LibraryContext._throwLibraryCycleLinkException (package:analyzer/src/dart/analysis/library_context.dart:321:5)
#1 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:188:11)
<asynchronous suspension>
#2 LibraryContext.load.<anonymous closure> (package:analyzer/src/dart/analysis/library_context.dart:246:7)
<asynchronous suspension>
#3 PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14)
<asynchronous suspension>
#4 LibraryContext.load (package:analyzer/src/dart/analysis/library_context.dart:244:5)
<asynchronous suspension>
#5 AnalysisDriver._computeUnitElement.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1508:7)
<asynchronous suspension>
#6 PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14)
<asynchronous suspension>
#7 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1127:22)
<asynchronous suspension>
#8 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2249:7)
<asynchronous suspension>
This came up at https://github.com/Dart-Code/Dart-Code/issues/4815 too, while typing import '/main.dart';
. I haven't been able to repro it on either Windows or macOS. The poster said they see different behaviour between Dart/Flutter but I'm not sure whether that's the cause or if there's something else different (like a version, or something cached for one of the projects).
Trying to build a small project to reproduce the issue.
Found that flutter clean
somehow solve the problem temporarily.
Still don't know which part triggers the issue, but it will happen after some time.
Only sure that with some conditions, type '/' inside import '' , will cause analyzer terminated.
While writing my flutter app I started noticing that whenever I start writing an import directive like
import '../'
, as soon as I write the slash the analyzer stops. I am usingcustom_lint
together withriverpod_lint
.Here is the Analyzer log, I made a Pastebin since it was exceeding the character limit. Dart Analyzer Log
I can't seem to reproduce the error in an empty project but it's been a week now and it's really frustrating having to wait for the analyzer to restart every time I write an import statement.
Let me know if you need other details since I am not familiar with debugging LSPs and the analyzer.