Skip to content

publish --dry-run analysis doesn't get sub-package (e.g., example) dependencies, causing bogus warnings #3618

@stuartmorgan-g

Description

@stuartmorgan-g

Environment

  • Dart version (run dart --version): Dart SDK version: 2.19.0-323.0.dev (dev) (Thu Oct 20 06:08:46 2022 -0700) on "macos_arm64"
  • OS kind and version (e.g. "Windows 10, version 1809" or "macOS 12.4"): macOS 12.6
  • Are you using the Chinese community mirror or a corporate firewall? No

Problem

The new analysis added in #3568 runs recursively over the whole package, but the get that runs before it doesn't, which can lead to false errors.

Example steps:

  1. git clone https://github.com/flutter/plugins (If you already have one, either make new one, or git clean -xfd the camera plugin.)
  2. cd plugins/packages/camera/camera
  3. git checkout 09a4a096d1a55f8cb4378e192202ffc5092ee618
  4. Update the version in pubspec.yaml to something that hasn't been published, so that publish --dry-run actually does something.
  5. dart pub publish --dry-run
  6. flutter pub get
  7. dart pub publish --dry-run

Expected behavior

No errors at step 5 or 7.

Actual behavior

Step 5 gives:

Package validation found the following potential issue:
* `dart analyze` found the following issue(s):
  Analyzing camera...
  
    error - example/integration_test/camera_test.dart:12:8 - Target of URI doesn't exist: 'package:integration_test/integration_test.dart'. Try creating the file referenced by the URI, or try using a URI for a file that does exist. - uri_does_not_exist
    error - example/integration_test/camera_test.dart:13:8 - Target of URI doesn't exist: 'package:path_provider/path_provider.dart'. Try creating the file referenced by the URI, or try using a URI for a file that does exist. - [...]ges
     info - example/integration_test/camera_test.dart:13:8 - The imported package 'path_provider' isn't a dependency of the importing package. Try adding a dependency for 'path_provider' in the 'pubspec.yaml' file. - depend_on_referenced_packages
     info - example/test/main_test.dart:5:8 - The imported package 'camera_example' isn't a dependency of the importing package. Try adding a dependency for 'camera_example' in the 'pubspec.yaml' file. - depend_on_referenced_packages
  
  9 issues found.

Package has 1 warning.

Step 7 works as expected:

Package has 0 warnings.

Note that all of the errors are coming from example. It appears that the pre-analysis resolution uses dart pub get logic, which only does the top-level package, but then it tries to analyze everything recursively. flutter pub get runs get for the example, fixing the issue.

This may seem contrived since it only happens if the tree is clean, but that's the common case in CI. This broke flutter/plugins.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions