dart_test_tools-4.7.0/.../test_import_linter.dart: Error: A value of type 'String?' can't be assigned to a variable of type 'DirectiveUri?'.
nzoschke opened this issue · comments
I'm getting an error trying to run this:
% dart run dart_pre_commit
Building package executable...
Failed to build dart_pre_commit:dart_pre_commit:
../../.pub-cache/hosted/pub.dartlang.org/dart_test_tools-4.7.0/lib/src/lint/test_import_linter.dart:105:32: Error: A value of type 'String?' can't be assigned to a variable of type 'DirectiveUri?'.
- 'DirectiveUri' is from 'package:analyzer/dart/element/element.dart' ('../../.pub-cache/hosted/pub.dartlang.org/analyzer-4.7.0/lib/dart/element/element.dart').
directiveUri = directive.element?.uri;
^
../../.pub-cache/hosted/pub.dartlang.org/dart_test_tools-4.7.0/lib/src/lint/test_import_linter.dart:107:32: Error: A value of type 'String?' can't be assigned to a variable of type 'DirectiveUri?'.
- 'DirectiveUri' is from 'package:analyzer/dart/element/element.dart' ('../../.pub-cache/hosted/pub.dartlang.org/analyzer-4.7.0/lib/dart/element/element.dart').
directiveUri = directive.element?.uri;
^
Failed to build dart_pre_commit:dart_pre_commit:
../../.pub-cache/hosted/pub.dartlang.org/dart_test_tools-4.7.0/lib/src/lint/test_import_linter.dart:105:32: Error: A value of type 'String?' can't be assigned to a variable of type 'DirectiveUri?'.
- 'DirectiveUri' is from 'package:analyzer/dart/element/element.dart' ('../../.pub-cache/hosted/pub.dartlang.org/analyzer-4.7.0/lib/dart/element/element.dart').
directiveUri = directive.element?.uri;
^
../../.pub-cache/hosted/pub.dartlang.org/dart_test_tools-4.7.0/lib/src/lint/test_import_linter.dart:107:32: Error: A value of type 'String?' can't be assigned to a variable of type 'DirectiveUri?'.
- 'DirectiveUri' is from 'package:analyzer/dart/element/element.dart' ('../../.pub-cache/hosted/pub.dartlang.org/analyzer-4.7.0/lib/dart/element/element.dart').
directiveUri = directive.element?.uri;
It was working so I'm guessing its related to flutter and other package upgrades in my project.
Trying to upgrade analyzer to 5.0.0 and I get some pub problems
flutter pub upgrade
Resolving dependencies...
Because test >=1.21.0 <1.21.6 depends on analyzer >=2.0.0 <5.0.0 and test >=1.21.6 <1.21.7 depends on test_api 0.4.14, test >=1.21.0 <1.21.7 requires analyzer >=2.0.0 <5.0.0 or test_api 0.4.14.
And because test >=1.21.7 <1.22.0 depends on test_api 0.4.15, test >=1.21.0 <1.22.0 requires analyzer >=2.0.0 <5.0.0 or test_api 0.4.14 or 0.4.15.
And because test >=1.22.0 <1.22.1 depends on test_api 0.4.16 and test >=1.22.1 depends on test_api 0.4.17, test >=1.21.0 requires test_api 0.4.14 or 0.4.15 or 0.4.16 or 0.4.17 or analyzer >=2.0.0 <5.0.0.
And because every version of flutter_test from sdk depends on test_api 0.4.12 and dart_test_tools >=4.5.3+1 depends on test ^1.21.4, if flutter_test from sdk and dart_test_tools >=4.5.3+1 then analyzer >=2.0.0 <5.0.0.
And because dart_pre_commit >=3.0.2+1 depends on dart_test_tools ^4.5.3+1 and jukelab depends on analyzer ^5.0.0, flutter_test from sdk is incompatible with dart_pre_commit >=3.0.2+1.
So, because jukelab depends on both dart_pre_commit ^4.0.0 and flutter_test from sdk, version solving failed.
This is on the flutter stable
channel. Trying beta
...
It's working fine on flutter beta
channel. So probably just a matter of time that flutter stable works with 4.0.0 of dart_pre_commit.
As a workaround, you can install the tool globally via dart pub global activate dart_pre_commit
and use it as dart pub global run dart_pre_commit [args...]
. Otherwise yes, you need to wait for the next flutter release