Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dartdoc failed: NoSuchMethodError: The getter 'element' was called on null #2594

Closed
Dinesh-DK opened this issue Mar 29, 2021 · 19 comments · Fixed by #2607
Closed

dartdoc failed: NoSuchMethodError: The getter 'element' was called on null #2594

Dinesh-DK opened this issue Mar 29, 2021 · 19 comments · Fixed by #2607
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Dinesh-DK
Copy link

When trying to run dartdoc in our library syncfusion_flutter_charts the dartdoc generation task fails with a dartdoc internal error message. Also this doesn't occur with the older versions of dartdoc(other than 0.40.0). I have attached the error log below.

used dartdoc version : 0.40.0

flutter_charts_dartdoc.txt


dartdoc failed: NoSuchMethodError: The getter 'element' was called on null.
Receiver: null
Tried calling: element
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      new ElementType.from (package:dartdoc/src/element_type.dart:29:11)
#2      new Extension (package:dartdoc/src/model/extension.dart:21:21)
#3      ModelElement._from (package:dartdoc/src/model/model_element.dart:330:14)
#4      new ModelElement.from (package:dartdoc/src/model/model_element.dart:278:40)
#5      Library.extensions.<anonymous closure> (package:dartdoc/src/model/library.dart:202:34)
#6      MappedIterator.moveNext (dart:_internal/iterable.dart:389:20)
#7      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:198:26)
#8      new _List._ofOther (dart:core-patch/array.dart:106:43)
#9      new _List.of (dart:core-patch/array.dart:57:18)
#10     new List.of (dart:core-patch/array_patch.dart:52:20)
#11     Iterable.toList (dart:core/iterable.dart:366:12)
#12     Library.extensions (package:dartdoc/src/model/library.dart:203:10)
#13     Library.modelElementsMap (package:dartdoc/src/model/library.dart:607:17)
#14     Library.allModelElements (package:dartdoc/src/model/library.dart:647:33)
#15     PackageGraph.allModelElements.<anonymous closure>.<anonymous closure> (package:dartdoc/src/model/package_graph.dart:915:48)
#16     SetMixin.forEach (dart:collection/set.dart:142:30)
#17     PackageGraph.allModelElements.<anonymous closure> (package:dartdoc/src/model/package_graph.dart:914:18)
#18     SetMixin.forEach (dart:collection/set.dart:142:30)
#19     PackageGraph.allModelElements (package:dartdoc/src/model/package_graph.dart:908:52)
#20     PackageGraph.precacheLocalDocs.sync_op (package:dartdoc/src/model/package_graph.dart:121:19)
#21     _SyncIterator.moveNext (dart:core-patch/core_patch.dart:181:26)
#22     Future.wait (dart:async/future.dart:393:26)
#23     PackageGraph.initializePackageGraph (package:dartdoc/src/model/package_graph.dart:73:18)
#24     PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:72:20)
<asynchronous suspension>
#25     Dartdoc.generateDocsBase (package:dartdoc/dartdoc.dart:182:20)
<asynchronous suspension>
#26     Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:223:28)
<asynchronous suspension>
#27     Dartdoc.executeGuarded.<anonymous closure> (package:dartdoc/dartdoc.dart:500:9)
<asynchronous suspension>

Program returned code  : 255
@jcollins-g
Copy link
Contributor

I am unable to reproduce this problem locally either with v0.40.0 or the newly released v0.41.0.

Can you please specify the version of Flutter you are using, and confirm that you have run "pub upgrade" if you are using a local checkout of dartdoc?

@jcollins-g jcollins-g added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) needs-info Additional information needed from the issue author P1 A high priority bug; for example, a single project is unusable or has many test failures labels Mar 30, 2021
@jcollins-g
Copy link
Contributor

@Dinesh-DK Will close in a couple days unless I hear back, assuming that it is related to previously closed bugs on this topic. This is the first report of this problem with 0.40.0 however so I'd like to be sure before doing that.

@BrianM-saltus
Copy link

BrianM-saltus commented Apr 1, 2021

I am running into the same issue. Today is the first time I have used dartdoc. I used it on two programs a dart cli program and a flutter program. The cli program worked without issue, however I see the same error as Dinesh-DK when trying to use it with the flutter program.

I even created a fresh flutter app and the error still happened. I am running Flutter 2.0.3. Also i checked i am using 0.41 of dartdoc

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.18363.1440], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.2)
[√] Android Studio (version 4.0)
[√] VS Code (version 1.55.0)
[√] Connected device (2 available)

@jcollins-g jcollins-g removed the needs-info Additional information needed from the issue author label Apr 1, 2021
@jcollins-g
Copy link
Contributor

This is very odd, especially since pub.dev seems to be processing flutter packages just fine. Perhaps it has something to do with Windows. Will investigate.

@BrianM-saltus
Copy link

Thank you. If you want/need me to try anything please just ask.

@jcollins-g
Copy link
Contributor

jcollins-g commented Apr 5, 2021

Swinging back around to this, I've tried several ways of reproducing this on non-Windows platforms but failed. I am working on getting access to/setting up a Dart development platform on a Windows system to reproduce the problem.

Some questions I have:

  • Is this issue being experienced by anyone not on Windows?
  • Does flutter analyze return with no errors on your project? That is a prerequisite for dartdoc to function properly. It does return with no errors for me on syncfusion, but again that package works fine for me, not tried on Windows yet.

@wolfenrain
Copy link

A member of my team is currently experiencing this problem as well on one of the packages I maintain. Both in the CI/CD (Linux) and locally (Mac).

Using dartdoc v0.39.0. And it only occurs on our newly created web interface package. After reviewing our own code I wasn't able to find anything strange with it as to why it might occur but it might give some insights?

The relevant source can be found here

@nikto-b
Copy link

nikto-b commented Apr 6, 2021

Have reproduced
Linux
dartdoc version: 0.39.0

[✓] Flutter (Channel stable, 2.0.4, on Linux, locale ru_RU.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)

Steps to reproduce:

  1. Run Linux
  2. flutter create dartdoc_bug_test
  3. cd dartdoc_bug_test
  4. dartdoc
  5. That's it
Documenting dartdoc_bug_test...
\
dartdoc failed: NoSuchMethodError: The getter 'element' was called on null.
Receiver: null
Tried calling: element
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      new ElementType.from (package:dartdoc/src/element_type.dart:29:11)
#2      new Extension (package:dartdoc/src/model/extension.dart:21:21)
#3      ModelElement._from (package:dartdoc/src/model/model_element.dart:330:14)
#4      new ModelElement.from (package:dartdoc/src/model/model_element.dart:278:40)
#5      Library.extensions.<anonymous closure> (package:dartdoc/src/model/library.dart:202:34)
#6      MappedIterator.moveNext (dart:_internal/iterable.dart:389:20)
#7      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:198:26)
#8      new _List._ofOther (dart:core-patch/array.dart:106:43)
#9      new _List.of (dart:core-patch/array.dart:57:18)
#10     new List.of (dart:core-patch/array_patch.dart:52:20)
#11     Iterable.toList (dart:core/iterable.dart:366:12)
#12     Library.extensions (package:dartdoc/src/model/library.dart:203:10)
#13     Library.modelElementsMap (package:dartdoc/src/model/library.dart:607:17)
#14     Library.allModelElements (package:dartdoc/src/model/library.dart:647:33)
#15     PackageGraph.allModelElements.<anonymous closure>.<anonymous closure> (package:dartdoc/src/model/package_graph.dart:915:48)
#16     SetMixin.forEach (dart:collection/set.dart:142:30)
#17     PackageGraph.allModelElements.<anonymous closure> (package:dartdoc/src/model/package_graph.dart:914:18)
#18     SetMixin.forEach (dart:collection/set.dart:142:30)
#19     PackageGraph.allModelElements (package:dartdoc/src/model/package_graph.dart:908:52)
#20     PackageGraph.precacheLocalDocs.sync_op (package:dartdoc/src/model/package_graph.dart:121:19)
#21     _SyncIterator.moveNext (dart:core-patch/core_patch.dart:181:26)
#22     Future.wait (dart:async/future.dart:393:26)
#23     PackageGraph.initializePackageGraph (package:dartdoc/src/model/package_graph.dart:73:18)
#24     PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:72:20)
<asynchronous suspension>
#25     Dartdoc.generateDocsBase (package:dartdoc/dartdoc.dart:182:20)
<asynchronous suspension>
#26     Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:223:28)
<asynchronous suspension>
#27     Dartdoc.executeGuarded.<anonymous closure> (package:dartdoc/dartdoc.dart:500:9)
<asynchronous suspension>

@nikto-b
Copy link

nikto-b commented Apr 6, 2021

Fixed by updating to dartdoc version: 0.40.0

@jcollins-g
Copy link
Contributor

I can not reproduce this problem on 0.40.0 or higher, but can reliably reproduce it on 0.39.0 -- this is a known bug with that version. For anyone reporting this issue, have you checked that your PATH is correct and pointing to a dartdoc that reports greater than 0.39.0?

I am going to add some debugging output on exceptions so that it is clear which version is being executed for future crashes -- it's particularly confusing since people can use pub global activate dartdoc as well as the dartdoc from either a Dart SDK or Flutter SDK installation.

@sjimbonator
Copy link

I am the team member @wolfenrain mentioned. We are still having this problem on dartdoc version 0.42.0 but only on one specific package.

@jcollins-g
Copy link
Contributor

I am the team member @wolfenrain mentioned. We are still having this problem on dartdoc version 0.42.0 but only on one specific package.

You are certain the correct version of dartdoc is being executed in your use case? I have tried everything to reproduce this outside of 0.39.0. The stable version of the SDK included with the last stable flutter still has dartdoc 0.39.0, and if your PATH is not correctly set up you might be using that and therefore reproduce the crash.

@sjimbonator
Copy link

I am the team member @wolfenrain mentioned. We are still having this problem on dartdoc version 0.42.0 but only on one specific package.

You are certain the correct version of dartdoc is being executed in your use case? I have tried everything to reproduce this outside of 0.39.0. The stable version of the SDK included with the last stable flutter still has dartdoc 0.39.0, and if your PATH is not correctly set up you might be using that and therefore reproduce the crash.

Hey sorry the dartdoc version on my path was still 0.39.0 like you said. Updating to 0.40.0 fixed the issue.

My mistake was that I used pub global activate dartdoc to update dartdoc but I was still trying to generate docs from path. Using flutter pub global run dartdoc:dartdoc works for me now.

@jcollins-g
Copy link
Contributor

It is somewhat confusing given there are multiple ways to access the package. #2607 should make it more clear which version you are using in the event of an exception for future releases.

@BrianM-saltus
Copy link

running pub global run dartdoc:dartdoc instead of just dartdoc also fixed it for me. Thank you to everyone.

@danfleck
Copy link

danfleck commented Sep 8, 2021

I know this is closed, but I just got it again. Thoughts?

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.60.0)
[✓] Connected device (2 available)

• No issues found!

Steps:

  1. flutter create dartdoc_bug_test
  2. cd dartdoc_bug_test
  3. dartdoc
dartdoc 3.0.0 (/Users/REDACTED/flutter_sdk/flutter/.pub-cache/global_packages/dartdoc/bin/dartdoc.dart-2.13.4.snapshot) failed: NoSuchMethodError: The getter 'name' was called on null.
Receiver: null
Tried calling: name
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1      new Package.fromPackageMeta (package:dartdoc/src/model/package.dart:52:35)
#2      PackageGraph.addLibraryToGraph (package:dartdoc/src/model/package_graph.dart:67:40)
#3      PubPackageBuilder._parseLibraries (package:dartdoc/src/model/package_builder.dart:217:23)
<asynchronous suspension>
#4      PubPackageBuilder.getLibraries (package:dartdoc/src/model/package_builder.dart:396:5)
<asynchronous suspension>
#5      PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:69:5)
<asynchronous suspension>
#6      Dartdoc.generateDocsBase (package:dartdoc/dartdoc.dart:202:20)
<asynchronous suspension>
#7      Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:249:28)
<asynchronous suspension>
#8      Dartdoc.executeGuarded.<anonymous closure> (package:dartdoc/dartdoc.dart:512:9)
<asynchronous suspension>

@jcollins-g
Copy link
Contributor

@danfleck does your package analyze without errors?

@jcollins-g
Copy link
Contributor

jcollins-g commented Sep 8, 2021

also, it looks like the version line is saying something impossible (that this is the dartdoc version included with Dart 2.13.4, and that it is version 3.0.0). Not sure what's going on there. (edit: never mind, looks like it is a version run via pub global activate on 2.13.4)

@danfleck
Copy link

danfleck commented Sep 8, 2021

The package is essentially empty, but it does analyze without error.

# dart analyze

Analyzing dartdoc_bug_test...          7.4s
No issues found!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants