dart-lang / pana

Package ANAlysis for Dart
https://pub.dev/packages/pana
BSD 3-Clause "New" or "Revised" License
205 stars 44 forks source link

pana incorrectly reports: "SEVERE: `dart pub outdated` failed" #1254

Open felangel opened 1 year ago

felangel commented 1 year ago

pana . reports that dart pub outdated failed but running dart pub outdated succeeds with no errors. The error pana reports also seems incorrect because every version of mason_api depends on http ^0.13.4 is false:

The mason_api pubspec.yaml:

name: mason_api
description: A Dart API client used by the Mason CLI (package:mason_cli).
version: 0.1.0-dev.10
homepage: https://github.com/felangel/mason
repository: https://github.com/felangel/mason
issue_tracker: https://github.com/felangel/mason/issues
documentation: https://github.com/felangel/mason/tree/master/packages/mason_cli#readme

environment:
  sdk: ">=2.19.0 <4.0.0"

dependencies:
  cli_util: ^0.4.0
  http: '>=0.13.3 <2.0.0'
  json_annotation: ^4.4.0
  meta: ^1.7.0
  path: ^1.8.1
  platform: ^3.1.0

dev_dependencies:
  build_runner: ^2.0.0
  json_serializable: ^6.1.4
  mocktail: ^1.0.0
  test: ^1.19.0

And the mason_api pubspec.lock entry for the resolved package:http dependency:

http:
    dependency: "direct main"
    description:
      name: http
      sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
      url: "https://pub.dev"
    source: hosted
    version: "1.1.0"

Full Pana Output:

pana . --no-warning                  
WARNING    Flutter SDK path was not specified, pana will use the default Dart SDK to run `dart analyze` on Flutter packages.
INFO       Running `/opt/homebrew/Cellar/dart/3.1.2/libexec/bin/dart --version`...
INFO       Running `flutter --no-version-check --version --machine`...
INFO       Running `git rev-parse --show-toplevel`...
INFO       Running `/opt/homebrew/Cellar/dart/3.1.2/libexec/bin/dart pub get --no-example`...
SEVERE     `dart pub outdated` failed.
           Because no versions of pub_updater match >0.4.0 <0.5.0 and pub_updater 0.4.0 depends on http ^1.0.0, pub_updater ^0.4.0 requires http ^1.0.0.
           And because every version of mason_api depends on http ^0.13.4, pub_updater ^0.4.0 is incompatible with mason_api.
INFO       Running `git init`...
INFO       Running `git remote add origin https://github.com/felangel/mason`...
INFO       Running `git remote show origin`...
INFO       Running `git fetch --depth 1 --no-recurse-submodules origin master`...
INFO       Running `git ls-tree -r --name-only --full-tree origin/master`...
INFO       Running `git show origin/master:bricks/hooks/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:bricks/random_color/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/basic/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/compile_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/dependency_install_failure/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/execution_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/malformed_pubspec/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/missing_run/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/relative_imports/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/run_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/unicode_hook/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_api/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/test/bricks/compilation_error/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/test/fixtures/new/hooks/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_logger/pubspec.yaml`...
INFO       Analyzing package...
INFO       Running `/opt/homebrew/Cellar/dart/3.1.2/libexec/bin/dart analyze --format machine bin`...
INFO       Running `/opt/homebrew/Cellar/dart/3.1.2/libexec/bin/dart analyze --format machine lib`...
INFO       Running `/opt/homebrew/Cellar/dart/3.1.2/libexec/bin/dart format --output=none --set-exit-if-changed /private/var/folders/2_/s6ghb9ns15j81dzw_mtd08440000gn/T/pana_XkqBWJ/packages/mason_cli/bin`...
INFO       Running `/opt/homebrew/Cellar/dart/3.1.2/libexec/bin/dart format --output=none --set-exit-if-changed /private/var/folders/2_/s6ghb9ns15j81dzw_mtd08440000gn/T/pana_XkqBWJ/packages/mason_cli/lib`...

## ✓ Follow Dart file conventions (30 / 30)
### [*] 10/10 points: Provide a valid `pubspec.yaml`

### [*] 5/5 points: Provide a valid `README.md`

### [*] 5/5 points: Provide a valid `CHANGELOG.md`

### [*] 10/10 points: Use an OSI-approved license

Detected license: `MIT`.

## ✓ Provide documentation (10 / 10)
### [*] 10/10 points: Package has an example

## ✓ Platform support (20 / 20)
### [*] 20/20 points: Supports 6 of 6 possible platforms (**iOS**, **Android**, **Web**, **Windows**, **MacOS**, **Linux**)

* ✓ Android
* ✓ iOS
* ✓ Windows
* ✓ Linux
* ✓ MacOS
* ✓ Web

## ✓ Pass static analysis (50 / 50)
### [*] 50/50 points: code has no errors, warnings, lints, or formatting issues

## ✗ Support up-to-date dependencies (10 / 20)
### [x] 0/10 points: All of the package dependencies are supported in the latest version

* Could not run `dart pub outdated`: `dart pub get` failed:

OUT: Resolving dependencies... ERR: Because no versions of pub_updater match >0.4.0 <0.5.0 and pub_updater 0.4.0 depends on http ^1.0.0, pub_updater ^0.4.0 requires http ^1.0.0. And because every version of mason_api depends on http ^0.13.4, pub_updater ^0.4.0 is incompatible with mason_api. So, because mason_cli depends on both mason_api ^0.1.0-dev.10 and pub_updater ^0.4.0, version solving failed.

You can try the following suggestion to make the pubspec resolve:

[*] 10/10 points: Package supports latest stable Dart and Flutter SDKs

Points: 120/130.


Full Dart Pub Outdated Output:

$ dart pub outdated Showing outdated packages. [*] indicates versions that are not the latest available.

Package Name Current Upgradable Resolvable Latest

direct dependencies: mason 0.1.0-dev.51 (overridden) 0.1.0-dev.51 (overridden) 0.1.0-dev.51 (overridden) 0.1.0-dev.51
mason_api
0.1.0-dev.10 (overridden) 0.1.0-dev.10 (overridden) 0.1.0-dev.10 (overridden) 0.1.0-dev.10

dev_dependencies: all up-to-date. You are already using the newest resolvable versions listed in the 'Resolvable' column. Newer versions, listed in 'Latest', may not be mutually compatible.


If I change the version constraint in `package:mason_cli` on `package:pub_updater` to `pub_updater: ">=0.3.0 <0.5.0"` then pana does not report this issue even though it resolves to `pub_updater` 0.4.0 in the lockfile:

```diff
- pub_updater: ^0.4.0
+ pub_updater: ">=0.3.0 <0.5.0"

Link to CI Failure: https://github.com/felangel/mason/actions/runs/6270259565/job/17027948266?pr=1080 Reproduction Repo: https://github.com/felangel/mason (directory: packages/mason_cli)

pana 0.21.36 Dart SDK version: 3.1.2 (stable) (Tue Sep 12 16:26:23 2023 +0000) on "macos_arm64"

sigurdm commented 1 year ago

I am not able to reproduce.

Can you spot something I am doing wrong?

> git clone https://github.com/felangel/mason
> cd mason/packages/mason_api
> pana .
WARNING    Flutter SDK path was not specified, pana will use the default Dart SDK to run `dart analyze` on Flutter packages.
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart --version`...
INFO       Running `flutter --no-version-check --version --machine`...
WARNING    pana might update or modify files in `.`.
           Analysis will begin in 15 seconds, hit CTRL+C to abort it.
           To remove this message, use `--no-warning`.
INFO       Running `git rev-parse --show-toplevel`...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart pub get --no-example`...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart pub outdated --json --up-to-date --no-dev-dependencies --no-dependency-overrides`...
INFO       Analyzing package...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart analyze --format machine lib`...
INFO       Running `git init`...
INFO       Running `git remote add origin https://github.com/felangel/mason`...
INFO       Running `git remote show origin`...
INFO       Running `git fetch --depth 1 --no-recurse-submodules origin master`...
INFO       Running `git ls-tree -r --name-only --full-tree origin/master`...
INFO       Running `git show origin/master:bricks/hooks/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:bricks/random_color/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/basic/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/compile_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/dependency_install_failure/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/execution_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/malformed_pubspec/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/missing_run/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/relative_imports/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/run_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/unicode_hook/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_api/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/test/bricks/compilation_error/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/test/fixtures/new/hooks/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_logger/pubspec.yaml`...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart format --output=none --set-exit-if-changed /tmp/pana_RAXXKO/packages/mason_api/lib`...

## ✓ Follow Dart file conventions (30 / 30)
### [*] 10/10 points: Provide a valid `pubspec.yaml`

### [*] 5/5 points: Provide a valid `README.md`

### [*] 5/5 points: Provide a valid `CHANGELOG.md`

### [*] 10/10 points: Use an OSI-approved license

Detected license: `MIT`.

## ✓ Provide documentation (10 / 10)
### [*] 10/10 points: Package has an example

## ✓ Platform support (20 / 20)
### [*] 20/20 points: Supports 5 of 6 possible platforms (**iOS**, **Android**, Web, **Windows**, **MacOS**, **Linux**)

* ✓ Android
* ✓ iOS
* ✓ Windows
* ✓ Linux
* ✓ MacOS

These platforms are not supported:

<details>
<summary>
Package not compatible with platform Web
</summary>

Because:
* `package:mason_api/mason_api.dart` that imports:
* `package:mason_api/src/mason_api.dart` that imports:
* `package:cli_util/cli_util.dart` that imports:
* `dart:io`
</details>

## ✓ Pass static analysis (50 / 50)
### [*] 50/50 points: code has no errors, warnings, lints, or formatting issues

## ✓ Support up-to-date dependencies (20 / 20)
### [*] 10/10 points: All of the package dependencies are supported in the latest version

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`cli_util`]|`^0.4.0`|0.4.0|0.4.0|
|[`http`]|`>=0.13.3 <2.0.0`|1.1.0|1.1.0|
|[`json_annotation`]|`^4.4.0`|4.8.1|4.8.1|
|[`meta`]|`^1.7.0`|1.10.0|1.10.0|
|[`path`]|`^1.8.1`|1.8.3|1.8.3|
|[`platform`]|`^3.1.0`|3.1.2|3.1.2|

<details><summary>Transitive dependencies</summary>

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`async`]|-|2.11.0|2.11.0|
|[`collection`]|-|1.18.0|1.18.0|
|[`http_parser`]|-|4.0.2|4.0.2|
|[`source_span`]|-|1.10.0|1.10.0|
|[`string_scanner`]|-|1.2.0|1.2.0|
|[`term_glyph`]|-|1.2.1|1.2.1|
|[`typed_data`]|-|1.3.2|1.3.2|
</details>

To reproduce run `dart pub outdated --no-dev-dependencies --up-to-date --no-dependency-overrides`.

[`cli_util`]: https://pub.dev/packages/cli_util
[`http`]: https://pub.dev/packages/http
[`json_annotation`]: https://pub.dev/packages/json_annotation
[`meta`]: https://pub.dev/packages/meta
[`path`]: https://pub.dev/packages/path
[`platform`]: https://pub.dev/packages/platform
[`async`]: https://pub.dev/packages/async
[`collection`]: https://pub.dev/packages/collection
[`http_parser`]: https://pub.dev/packages/http_parser
[`source_span`]: https://pub.dev/packages/source_span
[`string_scanner`]: https://pub.dev/packages/string_scanner
[`term_glyph`]: https://pub.dev/packages/term_glyph
[`typed_data`]: https://pub.dev/packages/typed_data

### [*] 10/10 points: Package supports latest stable Dart and Flutter SDKs

Points: 130/130.

pana 0.21.36 Dart SDK version: 3.1.2 (stable) (Tue Sep 12 16:26:23 2023 +0000) on "linux_x64"

felangel commented 1 year ago

I am not able to reproduce.

Can you spot something I am doing wrong?

> git clone https://github.com/felangel/mason
> cd mason/packages/mason_api
> pana .
WARNING    Flutter SDK path was not specified, pana will use the default Dart SDK to run `dart analyze` on Flutter packages.
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart --version`...
INFO       Running `flutter --no-version-check --version --machine`...
WARNING    pana might update or modify files in `.`.
           Analysis will begin in 15 seconds, hit CTRL+C to abort it.
           To remove this message, use `--no-warning`.
INFO       Running `git rev-parse --show-toplevel`...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart pub get --no-example`...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart pub outdated --json --up-to-date --no-dev-dependencies --no-dependency-overrides`...
INFO       Analyzing package...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart analyze --format machine lib`...
INFO       Running `git init`...
INFO       Running `git remote add origin https://github.com/felangel/mason`...
INFO       Running `git remote show origin`...
INFO       Running `git fetch --depth 1 --no-recurse-submodules origin master`...
INFO       Running `git ls-tree -r --name-only --full-tree origin/master`...
INFO       Running `git show origin/master:bricks/hooks/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:bricks/random_color/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/basic/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/compile_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/dependency_install_failure/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/execution_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/malformed_pubspec/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/missing_run/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/relative_imports/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/run_exception/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason/test/fixtures/unicode_hook/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_api/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/test/bricks/compilation_error/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_cli/test/fixtures/new/hooks/hooks/pubspec.yaml`...
INFO       Running `git show origin/master:packages/mason_logger/pubspec.yaml`...
INFO       Running `/usr/local/google/home/sigurdm/.dvm/darts/3.1.2/bin/dart format --output=none --set-exit-if-changed /tmp/pana_RAXXKO/packages/mason_api/lib`...

## ✓ Follow Dart file conventions (30 / 30)
### [*] 10/10 points: Provide a valid `pubspec.yaml`

### [*] 5/5 points: Provide a valid `README.md`

### [*] 5/5 points: Provide a valid `CHANGELOG.md`

### [*] 10/10 points: Use an OSI-approved license

Detected license: `MIT`.

## ✓ Provide documentation (10 / 10)
### [*] 10/10 points: Package has an example

## ✓ Platform support (20 / 20)
### [*] 20/20 points: Supports 5 of 6 possible platforms (**iOS**, **Android**, Web, **Windows**, **MacOS**, **Linux**)

* ✓ Android
* ✓ iOS
* ✓ Windows
* ✓ Linux
* ✓ MacOS

These platforms are not supported:

<details>
<summary>
Package not compatible with platform Web
</summary>

Because:
* `package:mason_api/mason_api.dart` that imports:
* `package:mason_api/src/mason_api.dart` that imports:
* `package:cli_util/cli_util.dart` that imports:
* `dart:io`
</details>

## ✓ Pass static analysis (50 / 50)
### [*] 50/50 points: code has no errors, warnings, lints, or formatting issues

## ✓ Support up-to-date dependencies (20 / 20)
### [*] 10/10 points: All of the package dependencies are supported in the latest version

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`cli_util`]|`^0.4.0`|0.4.0|0.4.0|
|[`http`]|`>=0.13.3 <2.0.0`|1.1.0|1.1.0|
|[`json_annotation`]|`^4.4.0`|4.8.1|4.8.1|
|[`meta`]|`^1.7.0`|1.10.0|1.10.0|
|[`path`]|`^1.8.1`|1.8.3|1.8.3|
|[`platform`]|`^3.1.0`|3.1.2|3.1.2|

<details><summary>Transitive dependencies</summary>

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`async`]|-|2.11.0|2.11.0|
|[`collection`]|-|1.18.0|1.18.0|
|[`http_parser`]|-|4.0.2|4.0.2|
|[`source_span`]|-|1.10.0|1.10.0|
|[`string_scanner`]|-|1.2.0|1.2.0|
|[`term_glyph`]|-|1.2.1|1.2.1|
|[`typed_data`]|-|1.3.2|1.3.2|
</details>

To reproduce run `dart pub outdated --no-dev-dependencies --up-to-date --no-dependency-overrides`.

[`cli_util`]: https://pub.dev/packages/cli_util
[`http`]: https://pub.dev/packages/http
[`json_annotation`]: https://pub.dev/packages/json_annotation
[`meta`]: https://pub.dev/packages/meta
[`path`]: https://pub.dev/packages/path
[`platform`]: https://pub.dev/packages/platform
[`async`]: https://pub.dev/packages/async
[`collection`]: https://pub.dev/packages/collection
[`http_parser`]: https://pub.dev/packages/http_parser
[`source_span`]: https://pub.dev/packages/source_span
[`string_scanner`]: https://pub.dev/packages/string_scanner
[`term_glyph`]: https://pub.dev/packages/term_glyph
[`typed_data`]: https://pub.dev/packages/typed_data

### [*] 10/10 points: Package supports latest stable Dart and Flutter SDKs

Points: 130/130.

pana 0.21.36 Dart SDK version: 3.1.2 (stable) (Tue Sep 12 16:26:23 2023 +0000) on "linux_x64"

I think you need to checkout the specific commit:

git checkout 6225b2e3f8bffbf35975d5a567acf87b17df8043

and also run pana from packages/mason_cli instead of packages/mason_api

cd packages/mason_cli && pana .