dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.27k stars 1.58k forks source link

Dart analysis issue. Missing library: dart:async #56798

Open mjablecnik opened 1 month ago

mjablecnik commented 1 month ago

Hello, I have some issue with Dart analysis. Can you say me how can I fix it? It is appeared in this my project: https://github.com/mjablecnik/startup_project Restart, clean cache, update/upgrade packages or IDE doesn't work..

Here is my log from Dart analysis:

Dart analysis issue

Internal error: Invalid argument(s): Missing library: dart:async

Version information

Details

Internal error: Invalid argument(s): Missing library: dart:async Libraries: [dart:core] Root children: [dart:core, dart:async] Readers: [] Log: [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67)

1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20)

2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22)

3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7)

4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16)

] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [removeLibraries][uriSet: {}][#0 LinkedElementFactory.removeLibraries (package:analyzer/src/summary2/linked_element_factory.dart:262:67) #1 LibraryContext.remove (package:analyzer/src/dart/analysis/library_context.dart:315:20) #2 AnalysisDriver._removePotentiallyAffectedLibraries (package:analyzer/src/dart/analysis/driver.dart:2037:22) #3 AnalysisDriver._applyPendingFileChanges (package:analyzer/src/dart/analysis/driver.dart:1510:7) #4 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2411:16) ] [load][targetLibrary: file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/test/http_client_test.dart = /Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/test/http_client_test.dart] #0 LinkedElementFactory.createLibraryElementForReading (package:analyzer/src/summary2/linked_element_factory.dart:153:7) #1 LinkedElementFactory.elementOfReference (package:analyzer/src/summary2/linked_element_factory.dart:212:14) #2 LinkedElementFactory.libraryOfUri (package:analyzer/src/summary2/linked_element_factory.dart:241:12) #3 LinkedElementFactory.libraryOfUri2 (package:analyzer/src/summary2/linked_element_factory.dart:245:19) #4 LinkedElementFactory.dartAsyncElement (package:analyzer/src/summary2/linked_element_factory.dart:52:12) #5 Linker._createTypeSystem (package:analyzer/src/summary2/link.dart:349:22) #6 Linker._buildOutlines (package:analyzer/src/summary2/link.dart:247:5) #7 Linker.link. (package:analyzer/src/summary2/link.dart:123:7) #8 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14) #9 Linker.link (package:analyzer/src/summary2/link.dart:122:5) #10 link (package:analyzer/src/summary2/link.dart:41:3) #11 LibraryContext.load.loadBundle. (package:analyzer/src/dart/analysis/library_context.dart:211:22) #12 OperationPerformanceImpl.runAsync (package:analyzer/src/util/performance/operation_performance.dart:174:14) #13 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:208:24) #14 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:158:9) #15 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:158:9) #16 LibraryContext.load. (package:analyzer/src/dart/analysis/library_context.dart:296:7) #17 PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14) #18 LibraryContext.load (package:analyzer/src/dart/analysis/library_context.dart:287:5) #19 AnalysisDriver._produceErrors (package:analyzer/src/dart/analysis/driver.dart:1976:5) #20 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1251:7) #21 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2455:7) ``` #0 LibraryContext._throwLibraryCycleLinkException (package:analyzer/src/dart/analysis/library_context.dart:425:5) #1 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:222:11) #2 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:158:9) #3 LibraryContext.load.loadBundle (package:analyzer/src/dart/analysis/library_context.dart:158:9) #4 LibraryContext.load. (package:analyzer/src/dart/analysis/library_context.dart:296:7) #5 PerformanceLog.runAsync (package:analyzer/src/dart/analysis/performance_logger.dart:50:14) #6 LibraryContext.load (package:analyzer/src/dart/analysis/library_context.dart:287:5) #7 AnalysisDriver._produceErrors (package:analyzer/src/dart/analysis/driver.dart:1976:5) #8 AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1251:7) #9 AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2455:7) ``` ## Debug log ``` 1727443745592 <= {"id":"7"} 1727443745843 <= {"event":"analysis.errors","params":{"file":"file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/pubspec.yaml","errors":[{"... 1727443745849 <= {"event":"analysis.errors","params":{"file":"file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/analysis_options.yaml","er... 1727443745849 <= {"event":"server.status","params":{"analysis":{"isAnalyzing":true}}} 1727443746021 <= {"event":"server.error","params":{"isFatal":false,"message":"Internal error: Invalid argument(s): Missing library: dart:async\nLibraries: [dart:core]\nRoot children: [dart:core, dart:... 1727443746824 => {"id":"8","method":"analysis.getHover","params":{"file":"file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/test/http_clie... 1727443747855 => {"id":"9","method":"server.shutdown","clientRequestTime":1727443747854} 1727443757542 started analysis server: /Users/martin/fvm/versions/3.24.3/bin/cache/dart-sdk/bin/dart language-server --client-id=Android-Studio --client-version=AI-241.19072.14 --protocol=analyzer 1727443757767 <= {"event":"server.connected","params":{"version":"1.38.0","pid":30445}} 1727443757777 <= {"id":"0","result":{"version":"1.38.0"}} 1727443757777 => {"id":"1","method":"server.setSubscriptions","params":{"subscriptions":["STATUS"]},"clientRequestTime":1727443757551} 1727443757778 => {"id":"2","method":"analysis.updateOptions","params":{"options":{"enableAsync":true,"enableDeferredLoading":true,"enableEnums":true,"enableNullAwareOperators":true,"generateDart2jsHin... 1727443757778 => {"id":"3","method":"server.setClientCapabilities","params":{"requests":["openUrlRequest","showMessageRequest"],"supportsUris":true},"clientRequestTime":1727443757552} 1727443757778 => {"id":"4","method":"analysis.setAnalysisRoots","params":{"included":["file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository"]... 1727443757778 => {"id":"5","method":"analysis.setPriorityFiles","params":{"files":["file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/test... 1727443757778 => {"id":"6","method":"analysis.setSubscriptions","params":{"subscriptions":{"CLOSING_LABELS":["file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/laye... 1727443757778 => {"id":"7","method":"edit.getAssists","params":{"file":"file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/test/mock_data.d... 1727443757778 => {"id":"8","method":"flutter.setSubscriptions","params":{"subscriptions":{"OUTLINE":["file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/proje... 1727443757780 <= {"id":"1"} 1727443757782 <= {"id":"2"} 1727443757784 <= {"id":"3"} 1727443757787 <= {"id":"5"} 1727443757790 <= {"id":"6"} 1727443757793 <= {"id":"8"} 1727443757795 <= {"id":"7","result":{"assists":[]}} 1727443758053 <= {"event":"analysis.errors","params":{"file":"file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/pubspec.yaml","errors":[{"... 1727443758063 <= {"event":"analysis.errors","params":{"file":"file:///Users/martin/Projects/Templates/startup_project/apps/flutter_project_template/layers/project_repository/analysis_options.yaml","er... 1727443758063 <= {"event":"server.status","params":{"analysis":{"isAnalyzing":true}}} 1727443758658 <= {"event":"server.error","params":{"isFatal":false,"message":"Internal error: Invalid argument(s): Missing library: dart:async\nLibraries: [dart:core]\nRoot children: [dart:core, dart:... ```
dart-github-bot commented 1 month ago

Summary: The user is experiencing an error during Dart analysis, where the "dart:async" library is missing. The error occurs despite restarting, cleaning the cache, updating packages, and upgrading the IDE. The user has provided their project repository, version information, and a detailed log of the error.

mraleph commented 1 month ago

Try close IDE, purge analysis driver cache by doing mv ~/.dartServer ~/.dartServer.bak and start IDE again.

If that helps then something is wrong with analysis driver cache got somehow corrupted and might be of interest to analyzer team.

mjablecnik commented 1 month ago

@mraleph Your advice didn't work, but I discovered that downgrading to Flutter version 3.22.0 solved the issue.

mjablecnik commented 1 month ago

Version where it works is:

martin at Martins-MacBook-Air startup_project >>> flutter --version
Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5dcb86f68f (5 months ago) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3
mjablecnik commented 1 month ago

I created a specific branch in my project: https://github.com/mjablecnik/startup_project/tree/dart-analysis-issue where I had the problem if you will need it for test.

bwilkerson commented 1 month ago

@scheglov