path
path copied to clipboard
Exception: NoSuchMethodError: The method 'pathFromUri' was called on null.
I'm running into issues running flutter test
- sometimes it's successful and other times it's not. I'm wondering if anyone has any ideas as to whether this is an issue on my end or not. Thanks.
This is an example of the output.
Shell: [ERROR:flutter/shell/testing/tester_main.cc(302)] Unhandled exception
Shell: Exception: NoSuchMethodError: The method 'pathFromUri' was called on null.
Shell: Receiver: null
Shell: Tried calling: pathFromUri(Instance of '_SimpleUri')
Shell: Stack trace: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
Shell: #1 Context.fromUri (package:path/src/context.dart:1006:19)
Shell: #2 Context.prettyUri (package:path/src/context.dart:1068:28)
Shell: #3 prettyUri (package:path/path.dart:458:34)
Shell: #4 Frame.library (package:stack_trace/src/frame.dart:105:12)
Shell: #5 Frame.location (package:stack_trace/src/frame.dart:119:14)
Shell: #6 Chain.toString.<anonymous closure>.<anonymous closure> (package:stack_trace/src/chain.dart:256:33)
Shell: #7 MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #8 ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #9 Chain.toString.<anonymous closure> (package:stack_trace/src/chain.dart:257:12)
Shell: #10 MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #11 ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #12 Chain.toString (package:stack_trace/src/chain.dart:258:8)
Shell: #13 LazyChain.toString (package:stack_trace/src/lazy_chain.dart:32:31)
Shell: #14 RemoteException.serialize (package:test_api/src/util/remote_exception.dart:51:48)
Shell: #15 RemoteListener._sendError (package:test_api/src/remote_listener.dart:158:32)
Shell: #16 RemoteListener.start.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:130:11)
Shell: #17 _rootRunBinary (dart:async/zone.dart:1222:13)
Shell: #18 _CustomZone.runBinary (dart:async/zone.dart:1107:19)
Shell: #19 runZonedGuarded.<anonymous closure> (dart:async/zone.dart:1601:18)
Shell: #20 _CustomZone.handleUncaughtError (dart:async/zone.dart:1076:19)
Shell: #21 Future._propagateToListeners (dart:async/future_impl.dart:610:16)
Shell: #22 Future._completeError (dart:async/future_impl.dart:537:5)
Shell: #23 Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:593:7)
Shell: #24 _rootRun (dart:async/zone.dart:1190:13)
Shell: #25 _CustomZone.run (dart:async/zone.dart:1093:19)
Shell: #26 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
Shell: #27 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
Shell: #28 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
Shell: #29 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
Shell:
I have put some logging in place and noticed that style
is sometimes null during the execution, but not always which you can see below:
style.pathFromUri(_parseUri(uri))
flutter test test/integration-tests
00:02 +0: loading <path>/test/integration-tests/ui/apps/forgot_password_test.dart
STYLE: posix
00:03 +0: loading <path>/test/integration-tests/ui/apps/settings_test.dart
STYLE: posix
Shell: STYLE: null
Shell: [ERROR:flutter/shell/testing/tester_main.cc(302)] Unhandled exception
Shell: Exception: NoSuchMethodError: The method 'pathFromUri' was called on null.
Shell: Receiver: null
Shell: Tried calling: pathFromUri(Instance of '_SimpleUri')
Shell: Stack trace: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
Shell: #1 Context.fromUri (package:path/src/context.dart:1006:19)
Shell: #2 Context.prettyUri (package:path/src/context.dart:1068:28)
Shell: #3 prettyUri (package:path/path.dart:458:34)
Shell: #4 Frame.library (package:stack_trace/src/frame.dart:105:12)
Shell: #5 Frame.location (package:stack_trace/src/frame.dart:119:14)
Shell: #6 Chain.toString.<anonymous closure>.<anonymous closure> (package:stack_trace/src/chain.dart:256:33)
Shell: #7 MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #8 ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #9 Chain.toString.<anonymous closure> (package:stack_trace/src/chain.dart:257:12)
Shell: #10 MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #11 ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #12 Chain.toString (package:stack_trace/src/chain.dart:258:8)
Shell: #13 LazyChain.toString (package:stack_trace/src/lazy_chain.dart:32:31)
Shell: #14 RemoteException.serialize (package:test_api/src/util/remote_exception.dart:51:48)
Shell: #15 RemoteListener._sendError (package:test_api/src/remote_listener.dart:158:32)
Shell: #16 RemoteListener.start.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:130:11)
Shell: #17 _rootRunBinary (dart:async/zone.dart:1222:13)
Shell: #18 _CustomZone.runBinary (dart:async/zone.dart:1107:19)
Shell: #19 runZonedGuarded.<anonymous closure> (dart:async/zone.dart:1601:18)
Shell: #20 _CustomZone.handleUncaughtError (dart:async/zone.dart:1076:19)
Shell: #21 Future._propagateToListeners (dart:async/future_impl.dart:610:16)
Shell: #22 Future._completeError (dart:async/future_impl.dart:537:5)
Shell: #23 Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:593:7)
Shell: #24 _rootRun (dart:async/zone.dart:1190:13)
Shell: #25 _CustomZone.run (dart:async/zone.dart:1093:19)
Shell: #26 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
Shell: #27 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
Shell: #28 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
Shell: #29 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
Shell:
Some additional info:
flutter doctor -v
flutter doctor -v
[✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale en-US)
• Flutter version 1.22.5 at /Users/nick/Code/flutter
• Framework revision 7891006299 (3 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/nick/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.9.3
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.0
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
Do you have a minimal reproduction case? What version of the package are you using, can you try updating?
I'm unable to see a code path where style
could be null
here.
@natebosch path is on ^1.7.0. I can try 1.8.0 but it looks like it's a pre-release. I don't have a specific reproduction case. Sometimes I don't run into this issue, most of the time I do when running flutter test
.
I didn't see anything obvious either about style
being null or getting cleared which was why I opened the issue. Thanks for taking a look. I'll post more if I find more. Let me know if you notice anything else. Thanks
I'm stumped.
The field is final.
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/context.dart#L55
The only 2 places which assign the field either have a null fallback, or assign directly to Style.platform
.
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/context.dart#L37-L38
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/context.dart#L49
Style.platform
can only hold a few values:
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/style.dart#L33-L45
And all of those values posix
, url
, and windows
are non-null because they are static final fields assigned with a call to a generative constructor.
Have you made any local modifications to the package before this started happening?
Yea. It seemed really odd.
I hadn't made any changes to the package prior to debugging, and even debugging was just logging out.
On Mon, Feb 8, 2021, 7:33 PM Nate Bosch [email protected] wrote:
I'm stumped.
The field is final.
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/context.dart#L55
The only 2 places which assign the field either have a null fallback, or assign directly to Style.platform.
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/context.dart#L37-L38
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/context.dart#L49
Style.platform can only hold a few values:
https://github.com/dart-lang/path/blob/10c778c799b2fc06036cbd0aa0e399ad4eb1ff5b/lib/src/style.dart#L33-L45
And all of those values posix, url, and windows are non-null because they are static final fields assigned with a call to a generative constructor.
Have you made any local modifications to the package before this started happening?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dart-lang/path/issues/103#issuecomment-775562485, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAPJF3Z463JELXDQDUZLLLS6B7F5ANCNFSM4VRSHFJQ .