Sdk: analyzer 0.38.3 is breaking build_runner builders on stable sdks

Created on 20 Sep 2019  路  8Comments  路  Source: dart-lang/sdk

Original issue https://github.com/dart-lang/build/issues/2451

We are now reproing this on our build bots as well that run on older sdks.

Example stack trace below, it looks like we are calling getSourceKind with a dart: uri and that is failing when it didn't previously? I don't understand how the SDK version makes a difference here, but I can repro this error in versions 2.3 through 2.5 of the sdk, but not the latest dev.

Invalid argument(s): Path must be absolute : dart:core
#0      MemoryResourceProvider._ensureAbsoluteAndNormalized (package:analyzer/file_system/memory_file_system.dart:244:7)
#1      MemoryResourceProvider.getFile (package:analyzer/file_system/memory_file_system.dart:94:5)
#2      FileSystemState.getFileForUri (package:analyzer/src/dart/analysis/file_state.dart:999:41)
#3      FileState._fileForRelativeUri (package:analyzer/src/dart/analysis/file_state.dart:564:21)
#4      FileState._refresh2 (package:analyzer/src/dart/analysis/file_state.dart:705:18)
#5      FileState.refresh (package:analyzer/src/dart/analysis/file_state.dart:401:14)
#6      FileSystemState.getFileForPath (package:analyzer/src/dart/analysis/file_state.dart:964:12)
#7      AnalysisDriver.getSourceKind (package:analyzer/src/dart/analysis/driver.dart:818:33)
<asynchronous suspension>
#8      AnalyzerResolver.isLibrary (package:build_resolvers/src/resolver.dart:83:24)
<asynchronous suspension>
#9      PerActionResolver.isLibrary (package:build_resolvers/src/resolver.dart:59:56)
#10     _DelayedResolver.isLibrary (package:build/src/builder/build_step_impl.dart:192:25)
<asynchronous suspension>
#11     ListClassesAndHierarchyBuilder.build (file:///usr/local/google/home/jakemac/build/build_runner_core/test/generate/resolution_test.dart:47:35)
#12     _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#13     ListClassesAndHierarchyBuilder.build (file:///usr/local/google/home/jakemac/build/build_runner_core/test/generate/resolution_test.dart:45:21)
#14     runBuilder.buildForInput (package:build/src/generate/run_builder.dart:55:21)
#15     _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#16     runBuilder.buildForInput (package:build/src/generate/run_builder.dart:45:29)
#17     MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
#18     ListIterator.moveNext (dart:_internal/iterable.dart:343:26)
#19     Future.wait (dart:async/future.dart:393:26)
#20     runBuilder.<anonymous closure> (package:build/src/generate/run_builder.dart:61:36)
#21     _rootRun (dart:async/zone.dart:1124:13)
#22     _CustomZone.run (dart:async/zone.dart:1021:19)
#23     _runZoned (dart:async/zone.dart:1516:10)
#24     runZoned (dart:async/zone.dart:1500:12)
#25     scopeLogAsync (package:build/src/builder/logging.dart:22:3)
#26     runBuilder (package:build/src/generate/run_builder.dart:61:9)
#27     _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#28     runBuilder (package:build/src/generate/run_builder.dart:33:24)
#29     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:478:19)
#30     _NoOpBuilderActionTracker.trackStage (package:build_runner_core/src/generate/performance_tracker.dart:300:15)
#31     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:476:23)
#32     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:77:64)
#33     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#34     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#35     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#36     _rootRunUnary (dart:async/zone.dart:1132:38)
#37     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#38     _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#39     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#40     Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#41     Future._complete (dart:async/future_impl.dart:473:7)
#42     _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#43     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:28:18)
#44     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:294:13)
#45     FailureReporter.clean (package:build_runner_core/src/logging/failure_reporter.dart)
#46     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:77:64)
#47     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#48     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#49     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#50     _rootRunUnary (dart:async/zone.dart:1132:38)
#51     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#52     _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#53     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#54     Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#55     Future._completeWithValue (dart:async/future_impl.dart:483:5)
#56     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
#57     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#58     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#59     _rootRun (dart:async/zone.dart:1124:13)
#60     _CustomZone.run (dart:async/zone.dart:1021:19)
#61     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#62     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#63     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#64     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#65     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:115:13)
#66     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:5)
area-analyzer type-bug

Most helpful comment

downgrade analyzer version from 0.38.3 to 0.38.2

dependencies:
  //analyzer: ^0.38.2
  analyzer: 0.38.2

All 8 comments

downgrade analyzer version from 0.38.3 to 0.38.2

dependencies:
  //analyzer: ^0.38.2
  analyzer: 0.38.2

Possibly related (though it's a different error message): https://github.com/dart-lang/sdk/issues/38511

EDIT: Downgrading to 0.38.2 fixed my error, so I'll close my issue as a duplicate.

After further discussion we decided to fix this in package:build.

Since which version is this fixed then?

@marcelgarus , the fix was in build_resolvers in 1.1.1. Please use a pub upgrade and ensure you have that version of build_resolvers.

Thanks a lot 馃槃 I'm using Flutter, so adding build_resolvers: ^1.1.1 to my dev_dependencies worked

i have error

retrofit: ^1.3.4
logger: ^0.9.1
json_annotation: ^3.0.1

dart_json_mapper:

dio: ^3.0.9

dev_dependencies:
flutter_test:
sdk: flutter
retrofit_generator: ^1.3.4
build_runner: ^1.10.0
json_serializable: ^3.3.0

E:\flutter\ezee_manager_pro>flutter packages pub run build_runner build
Could not find package "build_runner". Did you forget to add a dependency?
pub finished with exit code 65

::bump bump::

Anyone find out anything on this? Not sure how this issue is closed. Its definitely not resolved. Getting similar errors trying to run json_annotation package on a model class.

Deps:

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.3
  provider: ^4.3.1
  equatable: ^1.2.2
  json_annotation: ^3.0.1

dev_dependencies:
  # Analyser
  analyzer: ^0.39.14
  # effective_dart: ^1.2.0

  # Codegen/Builders
  build_resolvers: ^1.1.1
  build_runner: ^1.10.0
  json_serializable: ^3.3.0

  flutter_test:
    sdk: flutter

and output from flutter pub run build_runner build --enable-experiment=non-nullable

Waiting for another flutter command to release the startup lock...                            
[INFO] Generating build script...                                                             
[INFO] Generating build script completed, took 507ms                                          

[WARNING] Deleted previous snapshot due to missing asset graph.                               
[INFO] Creating build script snapshot......                                                   
[INFO] Creating build script snapshot... completed, took 15.2s                                



You have hit a bug in build_runner                                                            
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues     


Bad state: Attempting to enable experiments `[non-nullable]`, but the current SDK             
language version does not match your `analyzer` package language version:                     

Analyzer language version: 2.10.0                                                             
SDK language version: 2.9.0                                                                   

In order to use experiments you will need to upgrade or downgrade your                        
`analyzer` package dependency such that its language version matches that of                  
your current SDK, see https://github.com/dart-lang/build/issues/2685.                         

Note that you may or may not have a direct dependency on the `analyzer`                       
package in your `pubspec.yaml`, so you may have to add that. You can see your                 
current version by running `pub deps`.

package:build_resolvers/src/resolver.dart 362:5             _featureSet
package:build_resolvers/src/resolver.dart 212:19            new AnalyzerResolvers
package:build_runner_core/src/generate/options.dart 203:19  BuildOptions.create
package:build_runner/src/generate/build.dart 85:36          build
package:build_runner/src/entrypoint/build.dart 35:24        BuildCommand._run
package:build_runner/src/entrypoint/build.dart 31:15        BuildCommand.run.<fn>
dart:async                                                  runZoned
package:build/src/experiments.dart 18:5                     withEnabledExperiments
package:build_runner/src/entrypoint/build.dart 30:12        BuildCommand.run
package:args/command_runner.dart 197:27                     CommandRunner.runCommand
package:args/command_runner.dart 112:25                     CommandRunner.run.<fn>
dart:async                                                  new Future.sync
package:args/command_runner.dart 112:14                     CommandRunner.run
package:build_runner/src/entrypoint/run.dart 25:31          run
.dart_tool/build/entrypoint/build.dart 22:22                main

pub finished with exit code 1

Was this page helpful?
0 / 5 - 0 ratings