Skip to content

crash on near-empty package #2778

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

Closed
jcollins-g opened this issue Sep 8, 2021 · 10 comments · Fixed by #2781
Closed

crash on near-empty package #2778

jcollins-g opened this issue Sep 8, 2021 · 10 comments · Fixed by #2781
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

@jcollins-g
Copy link
Contributor

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>

Originally posted by @danfleck in #2594 (comment)

@jcollins-g jcollins-g added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P1 A high priority bug; for example, a single project is unusable or has many test failures labels Sep 8, 2021
@jcollins-g
Copy link
Contributor Author

I don't know why some users seem to encounter this while others do not, that remains a bit of a mystery.

Whether FLUTTER_ROOT is set is another question I have. We should be warning about that, but if the warning is broken it could lead to a problem here.

@srawlins
Copy link
Member

srawlins commented Sep 8, 2021

What does near-empty mean? No .dart files?

@danfleck
Copy link

danfleck commented Sep 8, 2021

`/Users/REDACTED/temp/dartdoc_bug_test# echo $FLUTTER_ROOT

/Users/REDACTED/flutter_sdk/flutter`

@danfleck
Copy link

danfleck commented Sep 8, 2021

Near empty just meant that I haven't changed anything after running.

flutter create dartdoc_bug_test

@abarisain
Copy link

abarisain commented Sep 9, 2021

Ran into the same issue with flutter 2.2.3.

Running flutter upgrade (upgrading to 2.5.0), then deactivate and finally flutter pub global activate dartdoc fixed it.

➜ flutter doctor -v
[✓] Flutter (Channel stable, 2.5.0, on macOS 12.0 21A5506j darwin-x64, locale en-GB)

@danfleck
Copy link

danfleck commented Sep 9, 2021

tl;dr; -- It's now working for me. I had to do a few steps I'll document below.

As @abarisain said, I ran flutter upgrade and then deactivated and reactivated dartdoc ( flutter pub global activate dartdoc)

After that it worked on the flutter project created without any changes ( flutter create dartdoc_bug_test )

However, when I ran it on my "real" Flutter application it failed with:

dartdoc 3.0.0 (/Users/REDACTED/flutter_sdk/flutter/.pub-cache/global_packages/dartdoc/bin/dartdoc.dart-2.14.0.snapshot) failed: fatal error: unable to locate the input directory at /Users/REDACTED/flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.3.0/lib/src/expect..

I ran: flutter pub cache repair

That command failed on dartdoc with:

Building package executables...
Failed to build dartdoc:dartdoc:
Error: Couldn't resolve the package 'dartdoc' in 'package:dartdoc/dartdoc.dart'.
Error: Couldn't resolve the package 'dartdoc' in 'package:dartdoc/options.dart'.
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:9:8: Error: Not found: 'package:dartdoc/dartdoc.dart'
import 'package:dartdoc/dartdoc.dart';
       ^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:10:8: Error: Not found: 'package:dartdoc/options.dart'
import 'package:dartdoc/options.dart';
       ^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:15:35: Error: Getter not found: 'pubPackageMetaProvider'.
  var config = await parseOptions(pubPackageMetaProvider, arguments);
                                  ^^^^^^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:15:22: Error: Method not found: 'parseOptions'.
  var config = await parseOptions(pubPackageMetaProvider, arguments);
                     ^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:20:33: Error: Method not found: 'PhysicalPackageConfigProvider'.
  final packageConfigProvider = PhysicalPackageConfigProvider();
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:22:33: Error: Getter not found: 'pubPackageMetaProvider'.
      PubPackageBuilder(config, pubPackageMetaProvider, packageConfigProvider);
                                ^^^^^^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:22:7: Error: Method not found: 'PubPackageBuilder'.
      PubPackageBuilder(config, pubPackageMetaProvider, packageConfigProvider);
      ^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:24:15: Error: Getter not found: 'Dartdoc'.
      ? await Dartdoc.fromContext(config, packageBuilder)
              ^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:25:15: Error: Getter not found: 'Dartdoc'.
      : await Dartdoc.withEmptyGenerator(config, packageBuilder);
              ^^^^^^^
Failed to reactivate dartdoc 3.0.0: Failed to build dartdoc:dartdoc:
Error: Couldn't resolve the package 'dartdoc' in 'package:dartdoc/dartdoc.dart'.
Error: Couldn't resolve the package 'dartdoc' in 'package:dartdoc/options.dart'.
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:9:8: Error: Not found: 'package:dartdoc/dartdoc.dart'
import 'package:dartdoc/dartdoc.dart';
       ^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:10:8: Error: Not found: 'package:dartdoc/options.dart'
import 'package:dartdoc/options.dart';
       ^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:15:35: Error: Getter not found: 'pubPackageMetaProvider'.
  var config = await parseOptions(pubPackageMetaProvider, arguments);
                                  ^^^^^^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:15:22: Error: Method not found: 'parseOptions'.
  var config = await parseOptions(pubPackageMetaProvider, arguments);
                     ^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:20:33: Error: Method not found: 'PhysicalPackageConfigProvider'.
  final packageConfigProvider = PhysicalPackageConfigProvider();
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:22:33: Error: Getter not found: 'pubPackageMetaProvider'.
      PubPackageBuilder(config, pubPackageMetaProvider, packageConfigProvider);
                                ^^^^^^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:22:7: Error: Method not found: 'PubPackageBuilder'.
      PubPackageBuilder(config, pubPackageMetaProvider, packageConfigProvider);
      ^^^^^^^^^^^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:24:15: Error: Getter not found: 'Dartdoc'.
      ? await Dartdoc.fromContext(config, packageBuilder)
              ^^^^^^^
../../../../../../flutter_sdk/flutter/.pub-cache/hosted/pub.dartlang.org/dartdoc-3.0.0/bin/dartdoc.dart:25:15: Error: Getter not found: 'Dartdoc'.
      : await Dartdoc.withEmptyGenerator(config, packageBuilder);
              ^^^^^^^
Binstubs exist for non-activated packages:
  From dartdoc: dartdoc
Failed to reactivate 1 package:
- dartdoc

Then I deactivated the global dartdoc (which actually didn't do anything because it wasn't active at this point).

Then I activated it again ( flutter pub global activate dartdoc )

Ran flutter pub get

Then ran dartdoc again and it worked. Hope this information helps.

@jcollins-g
Copy link
Contributor Author

jcollins-g commented Sep 9, 2021

ok. That might explain why I can never seem to reproduce this problem as I tend to start from a clean Flutter install. I could add a blurb to the exception handler suggesting either flutter pub global activate or pub global activate...

@jcollins-g
Copy link
Contributor Author

I'm hoping adding a message when this case comes up will help steer users toward a good place, see #2781

@abarisain
Copy link

Nice! I was very confused the first time I upgraded flutter and the global package broke, this will be very helpful. I believe flutter should do like nvm and reinstall global packages on upgrade but that's out of scope here.

Is dartdoc 3.0 compatible with dart 2.2.3 at all? I could swear that it was my first time installing it on my machine, so I couldn't have had a prior corrupted installation.

@jcollins-g
Copy link
Contributor Author

dartdoc requires Dart 2.12 to run, but should still be able to interpret code written for 2.9.

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.

4 participants