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

errors on dart packages #1880

Closed
pmagnuson opened this issue Dec 28, 2018 · 19 comments
Closed

errors on dart packages #1880

pmagnuson opened this issue Dec 28, 2018 · 19 comments
Labels
type-question A question about expected behavior or functionality

Comments

@pmagnuson
Copy link

pmagnuson commented Dec 28, 2018

On all my projects dartdoc fails with warnings:

warning: no canonical library found for dart-core.int, not linking ...
warning: no canonical library found for dart-core.Type, not linking ...
warning: no canonical library found for dart-core.List, not linking ...

Errors

Error: Could not resolve the package 'args' in 'package:args/args.dart'.
Error: Could not resolve the package 'path' in 'package:path/path.dart'.
Error: Could not resolve the package 'platform' in 'package:platform/platform.dart'.
file:///Users/phil/bin/flutter/dev/snippets/lib/main.dart:7:8: Error: Not found: 'package:args/args.dart'
import 'package:args/args.dart';
       ^
file:///Users/phil/bin/flutter/dev/snippets/lib/main.dart:8:8: Error: Not found: 'package:path/path.dart'
import 'package:path/path.dart' as path;
       ^
file:///Users/phil/bin/flutter/dev/snippets/lib/main.dart:9:8: Error: Not found: 'package:platform/platform.dart'
import 'package:platform/platform.dart';
       ^
Error: Could not resolve the package 'meta' in 'package:meta/meta.dart'.
file:///Users/phil/bin/flutter/dev/snippets/lib/configuration.dart:8:8: Error: Not found: 'package:path/path.dart'
import 'package:path/path.dart' as path;
       ^
file:///Users/phil/bin/flutter/dev/snippets/lib/snippets.dart:8:8: Error: Not found: 'package:path/path.dart'
import 'package:path/path.dart' as path;
       ^
Error: Could not resolve the package 'dart_style' in 'package:dart_style/dart_style.dart'.

FLUTTER_ROOT is set to /Users/phil/bin/flutter where flutter is installed. Have also tried /Users/phil/bin/flutter/bin

dart --version
Dart VM version: 2.1.0 (Tue Nov 13 18:22:02 2018 +0100) on "macos_x64"
dartdoc --version
dartdoc version: 0.24.1
@jcollins-g
Copy link
Contributor

Hi,

Have you run 'pub get' or 'flutter packages get` in the directory of the package you are trying to document?

@jcollins-g jcollins-g added the type-question A question about expected behavior or functionality label Jan 2, 2019
@pmagnuson
Copy link
Author

yes, this is a working flutter app, so flutter packages get has been run frequently.

@jcollins-g
Copy link
Contributor

@pmagnuson OK. Try doing pub global activate dartdoc first to get the latest version and see if that helps. If not, if you have a trivial reproduction case that might be helpful.

@jcollins-g
Copy link
Contributor

It looks like for some reason we just aren't seeing the .packages file for that project.

@pmagnuson
Copy link
Author

@jcollins-g Thank you for looking into this.
I have attached a couple of log files. dartdoc.log is the normal output log and dartdoc.error.log is the error report.

It is interesting to look at references to path.dart. It appears that when processing one of the source files, things proceed correctly. However when other flutter files are processed, the package is not found.

file:///Users/phil/bin/flutter/dev/snippets/lib/main.dart:8:8: Error: Not found: 'package:path/path.dart'
import 'package:path/path.dart' as path;

dartdoc.error.log
dartdoc.log
packages_copy.txt

@jcollins-g
Copy link
Contributor

jcollins-g commented Jan 2, 2019

This looks like a problem with the tooling support.

@gspencergoog

When I've run into this, flutter update-packages in the flutter directory corrects the issue for me.

As for the other warnings, --link-to-remote should allow the docs generated to link to Flutter and/or Dart and eliminate some of the "no canonical found" bits. The warnings for "unrecognized file" in the tree are indicating that the doc tree was not cleaned between dartdoc runs. Dartdoc does not currently do that for you.

@gspencergoog
Copy link
Collaborator

The reason for this is probably because it's picking up the Dart that from Homebrew instead of the Dart that Flutter uses. Try changing your PATH to include /Users/phil/bin/flutter/cache/dart-sdk/bin before the homebrew path.

@pmagnuson
Copy link
Author

pmagnuson commented Jan 7, 2019 via email

@pmagnuson
Copy link
Author

Thank you for your help.

I removed the homebrew version of dart.
I changed my path to put ~/bin/flutter/bin 1st.
I ran flutter update-packages
I ran ~/bin/flutter/bin/cache/dart-sdk/bin/dartdoc

I'm getting the same basic error. Here is the end of the log:

parsing /Users/phil/.pub-cache/hosted/pub.dartlang.org/intl-0.15.7/lib/src/file_data_reader.dart...
Initialized dartdoc with 528 libraries in 65.2 seconds
documenting geku
Generating docs for library main from package:geku/main.dart...
  warning: no canonical library found for dart-core.int, not linking, from dart-core.int: (file:///Users/phil/bin/flutter/bin/cache/pkg/sky_engine/lib/core/int.dart:25:16)
  warning: no canonical library found for dart-core.Type, not linking, from dart-core.Type: (file:///Users/phil/bin/flutter/bin/cache/pkg/sky_engine/lib/core/type.dart:10:16)
  warning: no canonical library found for dart-core.List, not linking, from dart-core.List: (file:///Users/phil/bin/flutter/bin/cache/pkg/sky_engine/lib/core/list.dart:54:16)
  warning: unresolved doc reference [new DiagnosticsNode.message]
    from main.MyApp.debugDescribeChildren: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2465:25)
    in documentation inherited from diagnostics.DiagnosticableTree.debugDescribeChildren: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2465:25)
  warning: unresolved doc reference [DiagnosticsProperty<Object>]
    from main.MyApp.debugDescribeChildren: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2465:25)
    in documentation inherited from diagnostics.DiagnosticableTree.debugDescribeChildren: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2465:25)
  warning: unresolved doc reference [RenderTable.debugDescribeChildren]
    from main.MyApp.debugDescribeChildren: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2465:25)
    in documentation inherited from diagnostics.DiagnosticableTree.debugDescribeChildren: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2465:25)
  error: tool execution failed: Tool "sample" returned non-zero exit code (255) when run as "/Users/phil/bin/flutter/bin/cache/dart-sdk/bin/dart /Users/phil/bin/flutter/dev/snippets/lib/main.dart --type=sample".
Input to sample was:

This example shows best practices for implementing [debugFillProperties]
illustrating use of all common [DiagnosticsProperty] subclasses and all
common [DiagnosticsProperty] parameters.

` ` `dart
class ExampleObject extends ExampleSuperclass {

  // ...various members and properties...

  @override
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    // Always add properties from the base class first.
    super.debugFillProperties(properties);

    // Omit the property name 'message' when displaying this String property
    // as it would just add visual noise.
    properties.add(StringProperty('message', message, showName: false));

    properties.add(DoubleProperty('stepWidth', stepWidth));

    // A scale of 1.0 does nothing so should be hidden.
    properties.add(DoubleProperty('scale', scale, defaultValue: 1.0));

    // If the hitTestExtent matches the paintExtent, it is just set to its
    // default value so is not relevant.
    properties.add(DoubleProperty('hitTestExtent', hitTestExtent, defaultValue: paintExtent));

    // maxWidth of double.infinity indicates the width is unconstrained and
    // so maxWidth has no impact.,
    properties.add(DoubleProperty('maxWidth', maxWidth, defaultValue: double.infinity));

    // Progress is a value between 0 and 1 or null. Showing it as a
    // percentage makes the meaning clear enough that the name can be
    // hidden.
    properties.add(PercentProperty(
      'progress',
      progress,
      showName: false,
      ifNull: '<indeterminate>',
    ));

    // Most text fields have maxLines set to 1.
    properties.add(IntProperty('maxLines', maxLines, defaultValue: 1));

    // Specify the unit as otherwise it would be unclear that time is in
    // milliseconds.
    properties.add(IntProperty('duration', duration.inMilliseconds, unit: 'ms'));

    // Tooltip is used instead of unit for this case as a unit should be a
    // terse description appropriate to display directly after a number
    // without a space.
    properties.add(DoubleProperty(
      'device pixel ratio',
      ui.window.devicePixelRatio,
      tooltip: 'physical pixels per logical pixel',
    ));

    // Displaying the depth value would be distracting. Instead only display
    // if the depth value is missing.
    properties.add(ObjectFlagProperty<int>('depth', depth, ifNull: 'no depth'));

    // bool flag that is only shown when the value is true.
    properties.add(FlagProperty('using primary controller', value: primary));

    properties.add(FlagProperty(
      'isCurrent',
      value: isCurrent,
      ifTrue: 'active',
      ifFalse: 'inactive',
      showName: false,
    ));

    properties.add(DiagnosticsProperty<bool>('keepAlive', keepAlive));

    // FlagProperty could have also been used in this case.
    // This option results in the text "obscureText: true" instead
    // of "obscureText" which is a bit more verbose but a bit clearer.
    properties.add(DiagnosticsProperty<bool>('obscureText', obscureText, defaultValue: false));

    properties.add(EnumProperty<TextAlign>('textAlign', textAlign, defaultValue: null));
    properties.add(EnumProperty<ImageRepeat>('repeat', repeat, defaultValue: ImageRepeat.noRepeat));

    // Warn users when the widget is missing but do not show the value.
    properties.add(ObjectFlagProperty<Widget>('widget', widget, ifNull: 'no widget'));

    properties.add(IterableProperty<BoxShadow>(
      'boxShadow',
      boxShadow,
      defaultValue: null,
      style: style,
    ));

    // Getting the value of size throws an exception unless hasSize is true.
    properties.add(DiagnosticsProperty<Size>.lazy(
      'size',
      () => size,
      description: '${ hasSize ? size : "MISSING" }',
    ));

    // If the `toString` method for the property value does not provide a
    // good terse description, write a DiagnosticsProperty subclass as in
    // the case of TransformProperty which displays a nice debugging view
    // of a Matrix4 that represents a transform.
    properties.add(TransformProperty('transform', transform));

    // If the value class has a good `toString` method, use
    // DiagnosticsProperty<YourValueType>. Specifying the value type ensures
    // that debugging tools always know the type of the field and so can
    // provide the right UI affordances. For example, in this case even
    // if color is null, a debugging tool still knows the value is a Color
    // and can display relevant color related UI.
    properties.add(DiagnosticsProperty<Color>('color', color));

    // Use a custom description to generate a more terse summary than the
    // `toString` method on the map class.
    properties.add(DiagnosticsProperty<Map<Listenable, VoidCallback>>(
      'handles',
      handles,
      description: handles != null ?
      '${handles.length} active client${ handles.length == 1 ? "" : "s" }' :
      null,
      ifNull: 'no notifications ever received',
      showName: false,
    ));
  }
}
` ` `
Stderr output was:
file:///Users/phil/bin/flutter/dev/snippets/lib/main.dart:1: Warning: Interpreting this as package URI, 'package:snippets/main.dart'.
Unhandled exception:
FileSystemException: Cannot open file, path = '/Users/phil/Documents/dev/snippets/config/skeletons/sample.html' (OS Error: No such file or directory, errno = 2)
#0      _File.throwIfError (dart:io/file_impl.dart:647:7)
#1      _File.openSync (dart:io/file_impl.dart:491:5)
#2      _File.readAsBytesSync (dart:io/file_impl.dart:551:18)
#3      _File.readAsStringSync (dart:io/file_impl.dart:596:18)
#4      SnippetGenerator._loadFileAsUtf8 (package:snippets/snippets.dart:178:17)
#5      SnippetGenerator.generate (package:snippets/snippets.dart:233:29)
#6      main (package:snippets/main.dart:139:26)
#7      _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:287:32)
#8      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

, from diagnostics.Diagnosticable.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2356:8)
  warning: unresolved doc reference [int]
    from main.MyApp.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/widgets/framework.dart:424:8)
    in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2356:8)
  warning: unresolved doc reference [DiagnosticsTreeStyle]
    from main.MyApp.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/widgets/framework.dart:424:8)
    in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2356:8)
  warning: unresolved doc reference [TransformProperty]
    from main.MyApp.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/widgets/framework.dart:424:8)
    in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2356:8)
  warning: unresolved doc reference [Matrix4]
    from main.MyApp.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/widgets/framework.dart:424:8)
    in documentation inherited from diagnostics.Diagnosticable.debugFillProperties: (file:///Users/phil/bin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart:2356:8)
  warning: no canonical library found for dart-core.Invocation, not linking, from dart-core.Invocation: (file:///Users/phil/bin/flutter/bin/cache/pkg/sky_engine/lib/core/invocation.dart:14:16)
  warning: no canonical library found for dart-core.String, not linking, from dart-core.String: (file:///Users/phil/bin/flutter/bin/cache/pkg/sky_engine/lib/core/string.dart:100:16)
  warning: no canonical library found for dart-core.bool, not linking, from dart-core.bool: (file:///Users/phil/bin/flutter/bin/cache/pkg/sky_engine/lib/core/bool.dart:15:7)
Validating docs...
found 13 warnings and 1 error
Documented 53 public libraries in 23.4 seconds

Generation failed: dartdoc encountered errors while processing.

@jcollins-g
Copy link
Contributor

@gspencergoog Actually, this looks different, you got past the import errors this time. Thanks so much for your patience! I think something is not right somewhere our pipeline for tool execution where a relative path for the skeleton to your CWD was used instead of the absolute path inside flutter.

@gspencergoog
Copy link
Collaborator

Yes, I think @jcollins-g is right, the line /Users/phil/Documents/dev/snippets/config/skeletons/sample.html should be /Users/phil/bin/flutter/dev/snippets/config/skeletons/sample.html instead, indicating that we're not using the right base directory for finding the snippet configuration.

Phil, are any of your projects open source projects that I can try running dartdoc on myself?

@pmagnuson
Copy link
Author

pmagnuson commented Jan 7, 2019

I just did an experiment of

flutter create trial
cd trial
dartdoc

I got the very same error. If that works correctly for you then there must be something about the way I have flutter installed.

@gspencergoog
Copy link
Collaborator

Indeed, I do get the same error when I do that, thanks for the repro.

The issue is that we're relying on the FLUTTER_ROOT environment variable being set to the root of the Flutter install. We should be able to find that without needing the env var, but in the mean time, if you set that, I think things will work (at least that fixes things when I run with the trial app).

This should work, from your project dir:

FLUTTER_ROOT=/Users/phil/bin/flutter dartdoc

@pmagnuson
Copy link
Author

still same error on my side.
FLUTTER_ROOT is set in env.

also the full command
FLUTTER_ROOT=/Users/phil/bin/flutter dartdoc
produces the same error.

@gspencergoog
Copy link
Collaborator

Ugh. OK, there must be some other difference between our setups.

I was able to get things to work on macOS in a trial app in an empty shell env (via env -i bash --norc) with just PATH, HOME, and FLUTTER_ROOT set.

Can you try this from your project dir, please, so we can rule out environment differences?:

env -i bash --norc
export HOME=~
export FLUTTER_ROOT=/Users/phil/bin/flutter
export PATH=$FLUTTER_ROOT/bin:$FLUTTER_ROOT/bin/cache/dart-sdk/bin:$PATH
dartdoc

And attach the error log, since there might be subtle differences that indicate what's happening.

@pmagnuson

This comment has been minimized.

@gspencergoog
Copy link
Collaborator

OK, I think I know the reason we get different answers: this is because of a bug that has already been fixed (#25243).

If you run this command:

git log -1 4a110b6227a10637e1671f1f7ced7faf4da45d5e

from the Flutter root directory, do you see a git log entry, or does it say something like "bad object"?

If it says "bad object", then you don't have the fix. Updating to the latest master build with flutter update should fix it, as long as you're on the master branch. If you're on the stable branch, you'll need to switch to master first with flutter channel master

@gspencergoog
Copy link
Collaborator

Note that switching to the master channel will move you from stable, and that it will naturally be less stable than our released stable branch.

@pmagnuson
Copy link
Author

Thank you very, very much for all your time on this. Now working with lots of warnings, but no errors.
I had the fix on the stable channel. Switching to master and upgrade proved the correct recipe.
Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

3 participants