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

pana not recognizing Flutter package when pubspec.yaml doesn't have Flutter SDK in environment #8486

Open
marianz-bonfire opened this issue Jan 21, 2025 · 5 comments

Comments

@marianz-bonfire
Copy link

marianz-bonfire commented Jan 21, 2025

Im encountering an issue when publishing a tarsier_local_storage package to pub.dev. The analysis fails, even though all tests run successfully when executed locally.

On my first publish, the package succeeded with 50/160 pub points. After making some fixes, I tried to publish a new version, but that's when the analysis started failing.

I am currently working on figuring out a solution. However, I wanted to raise this issue in the meantime in case you can provide immediate assistance.
I've reviewed previous issues, and while this might be a redundancy, I wanted to ensure it was highlighted in case it provides new insights or hasn't been fully addressed yet.

Commands executed locally

flutter --version
Flutter 3.16.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7f20e5d18c (1 year, 2 months ago) • 2023-11-27 09:47:30 -0800
Engine • revision 22b600f240
Tools • Dart 3.2.1 • DevTools 2.28.3
dart --version
Dart SDK version: 3.2.1 (stable) (Wed Nov 22 08:59:13 2023 +0000) on "windows_x64"

dart analyze
Analyzing tarsier_local_storage...
No issues found!
dart doc .

Documenting tarsier_local_storage...
Initialized dartdoc with 875 libraries
Generating docs for library tarsier_local_storage from package:tarsier_local_storage/tarsier_local_storage.dart...
no issues found
Documented 1 public library in 170.1 seconds
Success! Docs generated into d:\repository\tarsier_local_storage\doc\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 `dart.exe --version`...
INFO       Running `flutter.bat --no-version-check --version --machine`...
INFO       Running `git rev-parse --show-toplevel`...
INFO       Running `dart.exe pub get --no-example`...
INFO       Running `dart.exe pub outdated --json --up-to-date --no-dev-dependencies --no-dependency-overrides`...
INFO       Analyzing package...
INFO       Running `dart.exe analyze --format machine lib`...
INFO       Running `webpinfo C:\Users\Tarsier\AppData\Local\Temp\pana_8b7a150\.\assets/logo.png`...
SEVERE     'webpinfo' tool not found.
INFO       Running `cwebp C:\Users\Tarsier\AppData\Local\Temp\pana_8b7a150\.\assets/logo.png -o C:\Users\Tarsier\AppData\Local\Temp\83456978\gen\logo.webp`...
SEVERE     'cwebp' tool not found.
INFO       Running `gif2webp C:\Users\Tarsier\AppData\Local\Temp\pana_8b7a150\.\assets/logo.png -o C:\Users\Tarsier\AppData\Local\Temp\83456978\gen\logo.webp`...
SEVERE     'gif2webp' tool not found.
INFO       Running `git init`...
INFO       Running `git remote add origin https://github.com/marianz-bonfire/tarsier_local_storage`...
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       Unable to read "example/flutter_example/pubspec.yaml".
         Path "example/flutter_example/pubspec.yaml" is not normalized.
INFO       Running `git show origin/master:pubspec.yaml`...
INFO       Running `dart.exe format --output=none --set-exit-if-changed C:\Users\Tarsier\AppData\Local\Temp\pana_8b7a150\.\lib`...
INFO       Analyzing pub downgrade...
INFO       Running `dart.exe pub downgrade --no-example`...
INFO       Running `dart.exe analyze --format machine lib`...
INFO       [pub-downgrade-success]
INFO       Running `dart.exe pub upgrade --no-example`...
INFO       Running `dart.exe pub global activate dartdoc`...
INFO       Running `dart.exe pub global run dartdoc --output C:\Users\Tarsier\AppData\Local\Temp\pana.1737470742530.34555938\doc --sanitize-html --max-file-count 10000000 --max-total-size 2147483648 --no-validate-links`...
INFO       `dartdoc` completed:
         Documenting tarsier_local_storage...
         Discovering libraries...
         Linking elements...
         Precaching local docs for 612539 elements...
         Initialized dartdoc with 875 libraries
         Generating docs for library tarsier_local_storage.dart from package:tarsier_local_storage/tarsier_local_storage.dart...
         Documented 1 public library in 79.0 seconds
         Success! Docs generated into C:\Users\Tarsier\appdata\local\temp\pana.1737470742530.34555938\doc
         Found 0 warnings and 0 errors.

## ✓ 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 / 20)
### [*] 10/10 points: 20% or more of the public API has dartdoc comments

24 out of 24 API elements (100.0 %) have documentation comments.

### [x] 0/10 points: Package has an example and has no issues with screenshots

Found 4 issues. Showing the first 2:

* The system cannot find the file specified.

* The system cannot find the file specified.


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

SDK issues found:
<details>
<summary>
Package is not compatible with the Dart SDK.
</summary>

Because:
* `tarsier_local_storage` that depends on:
* `sqflite` that is a package requiring flutter.
</details>

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

These platforms are not supported:

<details>
<summary>
Package does not support platform `macOS`.
</summary>

Because:
* `package:tarsier_local_storage/tarsier_local_storage.dart` that declares support for platforms: `Android`, `iOS`, `Windows`, `Linux`, `Web`.
</details>

These issues are present but do not affect the score, because they may not originate in your package:

<details>
<summary>
Package does not support platform `Android`.
</summary>

Because:
* `package:tarsier_local_storage/tarsier_local_storage.dart` that imports:
* `package:tarsier_local_storage/src/tarsier_local_storage_base.dart` that imports:
* `package:tarsier_local_storage/src/database/database_web.dart` that imports:
* `package:sqflite_common_ffi_web/sqflite_ffi_web.dart` that declares support for platforms: `Web`.
</details>
<details>
<summary>
Package does not support platform `iOS`.
</summary>

Because:
* `package:tarsier_local_storage/tarsier_local_storage.dart` that imports:
* `package:tarsier_local_storage/src/tarsier_local_storage_base.dart` that imports:
* `package:tarsier_local_storage/src/database/database_web.dart` that imports:
* `package:sqflite_common_ffi_web/sqflite_ffi_web.dart` that declares support for platforms: `Web`.
</details>
<details>
<summary>
Package does not support platform `Windows`.
</summary>

Because:
* `package:tarsier_local_storage/tarsier_local_storage.dart` that imports:
* `package:tarsier_local_storage/src/base_table.dart` that imports:
* `package:sqflite/sqflite.dart` that declares support for platforms: `Android`, `iOS`, `macOS`.
</details>
<details>
<summary>
Package does not support platform `Linux`.
</summary>

Because:
* `package:tarsier_local_storage/tarsier_local_storage.dart` that imports:
* `package:tarsier_local_storage/src/base_table.dart` that imports:
* `package:sqflite/sqflite.dart` that declares support for platforms: `Android`, `iOS`, `macOS`.
</details>
<details>
<summary>
Package does not support platform `Web`.
</summary>

Because:
* `package:tarsier_local_storage/tarsier_local_storage.dart` that imports:
* `package:tarsier_local_storage/src/base_table.dart` that imports:
* `package:sqflite/sqflite.dart` that declares support for platforms: `Android`, `iOS`, `macOS`.
</details>

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


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

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`sqflite`]|`^2.3.2`|2.3.2|2.4.1|
|[`sqflite_common_ffi`]|`^2.3.2+1`|2.3.2+1|2.3.4+4|
|[`sqflite_common_ffi_web`]|`^0.4.2+3`|0.4.2+3|0.4.5+4|

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

|Package|Constraint|Compatible|Latest|
|:-|:-|:-|:-|
|[`args`]|-|2.5.0|2.6.0|
|[`async`]|-|2.11.0|2.12.0|
|[`characters`]|-|1.3.0|1.4.0|
|[`collection`]|-|1.18.0|1.19.1|
|[`dev_build`]|-|0.16.4+3|1.1.1+7|
|[`ffi`]|-|2.1.0|2.1.3|
|[`flutter`]|-|0.0.0|0.0.0|
|[`http`]|-|1.2.0|1.3.0|
|[`http_parser`]|-|4.0.2|4.1.2|
|[`js`]|-|0.6.7|0.7.1|
|[`material_color_utilities`]|-|0.5.0|0.12.0|
|[`meta`]|-|1.10.0|1.16.0|
|[`path`]|-|1.9.0|1.9.1|
|[`pool`]|-|1.5.1|1.5.1|
|[`process_run`]|-|1.0.1|1.2.2+1|
|[`pub_semver`]|-|2.1.4|2.1.5|
|[`sky_engine`]|-|0.0.99|0.0.99|
|[`source_span`]|-|1.10.1|1.10.1|
|[`sqflite_common`]|-|2.5.3|2.5.4+6|
|[`sqlite3`]|-|2.4.0|2.7.2|
|[`stack_trace`]|-|1.11.1|1.12.1|
|[`string_scanner`]|-|1.4.1|1.4.1|
|[`synchronized`]|-|3.1.0+1|3.3.0+3|
|[`term_glyph`]|-|1.2.2|1.2.2|
|[`typed_data`]|-|1.3.2|1.4.0|
|[`vector_math`]|-|2.1.4|2.1.4|
|[`web`]|-|0.3.0|1.1.0|
|[`yaml`]|-|3.1.2|3.1.3|
</details>

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

[`sqflite`]: https://pub.dev/packages/sqflite
[`sqflite_common_ffi`]: https://pub.dev/packages/sqflite_common_ffi
[`sqflite_common_ffi_web`]: https://pub.dev/packages/sqflite_common_ffi_web
[`args`]: https://pub.dev/packages/args
[`async`]: https://pub.dev/packages/async
[`characters`]: https://pub.dev/packages/characters
[`collection`]: https://pub.dev/packages/collection
[`dev_build`]: https://pub.dev/packages/dev_build
[`ffi`]: https://pub.dev/packages/ffi
[`flutter`]: https://pub.dev/packages/flutter
[`http`]: https://pub.dev/packages/http
[`http_parser`]: https://pub.dev/packages/http_parser
[`js`]: https://pub.dev/packages/js
[`material_color_utilities`]: https://pub.dev/packages/material_color_utilities
[`meta`]: https://pub.dev/packages/meta
[`path`]: https://pub.dev/packages/path
[`pool`]: https://pub.dev/packages/pool
[`process_run`]: https://pub.dev/packages/process_run
[`pub_semver`]: https://pub.dev/packages/pub_semver
[`sky_engine`]: https://pub.dev/packages/sky_engine
[`source_span`]: https://pub.dev/packages/source_span
[`sqflite_common`]: https://pub.dev/packages/sqflite_common
[`sqlite3`]: https://pub.dev/packages/sqlite3
[`stack_trace`]: https://pub.dev/packages/stack_trace
[`string_scanner`]: https://pub.dev/packages/string_scanner
[`synchronized`]: https://pub.dev/packages/synchronized
[`term_glyph`]: https://pub.dev/packages/term_glyph
[`typed_data`]: https://pub.dev/packages/typed_data
[`vector_math`]: https://pub.dev/packages/vector_math
[`web`]: https://pub.dev/packages/web
[`yaml`]: https://pub.dev/packages/yaml


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


### [*] 20/20 points: Compatible with dependency constraint lower bounds

`pub downgrade` does not expose any static analysis error.

Points: 150/160.

Analysis Results of pub dev

pub.dev analysis log
## Running analysis for "tarsier_local_storage" version "1.0.3"
STARTED: 2025-01-20T18:02:52.085900Z

### Starting pana
2025-01-20 18:03:06.984453 INFO: Running `dart pub unpack tarsier_local_storage:1.0.3 --output /tmp/pana-tarsier_local_storageLASFOV/tarsier_local_storage --no-resolve`...
2025-01-20 18:03:08.372572 INFO: Running `/home/worker/dart/stable/bin/dart --version`...
2025-01-20 18:03:08.399912 INFO: Running `/home/worker/flutter/stable/bin/flutter --no-version-check --version --machine`...
2025-01-20 18:03:08.554898 INFO: Running `git rev-parse --show-toplevel`...
2025-01-20 18:03:08.769973 INFO: Running `/home/worker/dart/stable/bin/dart pub get --no-example`...
2025-01-20 18:03:11.892049 INFO: Running `webpinfo /tmp/pana_CETRXP/./assets/logo.png`...
2025-01-20 18:03:11.912730 INFO: Running `cwebp /tmp/pana_CETRXP/./assets/logo.png -o /tmp/PIQHMW/gen/logo.webp`...
2025-01-20 18:03:11.975279 INFO: Running `webpinfo /tmp/PIQHMW/gen/logo.webp`...
2025-01-20 18:03:11.994106 INFO: Running `cwebp -resize 0 100 /tmp/PIQHMW/gen/logo.webp -o /tmp/PIQHMW/gen/100x100/logo.webp`...
2025-01-20 18:03:12.020590 INFO: Running `cwebp -resize 0 190 /tmp/PIQHMW/gen/logo.webp -o /tmp/PIQHMW/gen/190x190/logo.webp`...
2025-01-20 18:03:12.049635 INFO: Running `dwebp /tmp/PIQHMW/gen/100x100/logo.webp -o /tmp/PIQHMW/gen/100x100/logo.png`...
2025-01-20 18:03:12.071352 INFO: Running `dwebp /tmp/PIQHMW/gen/190x190/logo.webp -o /tmp/PIQHMW/gen/190x190/logo.png`...
2025-01-20 18:03:12.450012 INFO: Running `git init`...
2025-01-20 18:03:12.480165 INFO: Running `git remote add origin https://github.com/marianz-bonfire/tarsier_local_storage`...
2025-01-20 18:03:12.508111 INFO: Running `git remote show origin`...
2025-01-20 18:03:12.749198 INFO: Running `git fetch --depth 1 --no-recurse-submodules origin master`...
2025-01-20 18:03:13.273881 INFO: Running `git ls-tree -r --name-only --full-tree origin/master`...
2025-01-20 18:03:13.297487 INFO: Running `git show origin/master:example/flutter_example/pubspec.yaml`...
2025-01-20 18:03:13.330436 INFO: Running `git show origin/master:pubspec.yaml`...
2025-01-20 18:03:14.095359 INFO: Analyzing pub downgrade...
2025-01-20 18:03:14.100785 INFO: Running `/home/worker/dart/stable/bin/dart pub downgrade --no-example`...
2025-01-20 18:03:16.324506 INFO: [pub-downgrade-error]
2025-01-20 18:03:16.325799 INFO: Resolving dependencies...
2025-01-20 18:03:16.325799 INFO: Because tarsier_local_storage depends on sqflite >=1.1.2 which requires the Flutter SDK, version solving failed.
2025-01-20 18:03:16.325799 INFO: 
2025-01-20 18:03:16.325799 INFO: Flutter users should use `flutter pub` instead of `dart pub`.
2025-01-20 18:03:16.348100 INFO: Running `/home/worker/dart/stable/bin/dart pub upgrade --no-example`...
2025-01-20 18:03:17.849759 INFO: Writing summary.json
2025-01-20 18:03:17.852032 INFO: Running dartdoc post-processing
2025-01-20 18:03:17.854909 INFO: Creating .tar.gz archive
2025-01-20 18:03:17.866137 INFO: Finished post-processing
2025-01-20 18:03:17.874565 INFO: Finished .tar.gz archive
### Execution of pana exited 0
STOPPED: 2025-01-20T18:03:17.972289Z

Score screenshot

Image

As you can see, running the pana test locally, I received 150/160 pub points. However, on pub.dev, the package fails the analysis. This discrepancy is very puzzling since some of my previously published packages achieved 160/160 pub points on pub.dev, even though they were rated 150/160 locally with pana.

@sigurdm sigurdm transferred this issue from dart-lang/pub Jan 23, 2025
@sigurdm
Copy link
Contributor

sigurdm commented Jan 23, 2025

Seems like pana choses to resolve the package as a dart-only package. (Not sure why that doesn't happen locally, probably it falls back to the flutter sdk if you don't have a dart-only sdk installed .)

Try to augment the environment in pubspec.yaml with a flutter constraint.

environment:
  sdk: ^3.2.1
  flutter: ^3.16.0

@isoos
Copy link
Collaborator

isoos commented Jan 23, 2025

@marianz-bonfire: Your pubspec.yaml needs to specify your Flutter SDK constraints. Currently it only has the Dart SDK:

environment:
  sdk: ^3.2.1

It could be like:

environment:
  sdk: ^3.2.1
  flutter: ^2.27.0

Otherwise the analysis (pana) don't know upfront which SDK to use for it.

@sigurdm
Copy link
Contributor

sigurdm commented Jan 23, 2025

We could update pana on pub.dev to attempt resolving with the dart sdk first - and then with the flutter sdk,... somehow.

(I'd still recommend adding a flutter constraint though)

@isoos isoos changed the title 🔴 Analysis Issue on publishing package to pub.dev- ✅ Locally Successful pana not recognizing Flutter package when pubspec.yaml doesn't have Flutter SDK in environment Jan 23, 2025
@marianz-bonfire
Copy link
Author

@isoos @sigurdm
Thank you for the quick response and for pointing out the issue regarding the environment constraints in the pubspec.yaml file.

Interestingly, I didn’t expect this to be an issue because, based on my previous packages published on pub.dev, there were no problems even though their pubspec.yaml files followed a similar structure. Those packages achieved full analysis scores without the explicit Flutter SDK constraint.

I'll update the pubspec.yaml file to include the Flutter SDK constraint as per your suggestion. And provide feedback immediately after testing it and let you know the results.

Thank you again for your assistance and insights! 👏

@isoos
Copy link
Collaborator

isoos commented Jan 23, 2025

The exact method of detection is a bit more than that constrain:

  • it can depend on package: flutter (not sure if it is recommended anymore)
  • it can have top-level flutter key
  • it can have SDK constraint on Flutter

Maybe your other package depended on one of the first two?

https://github.com/dart-lang/pana/blob/7d36850821c6110cd62b79deb72f6e4ca4549bdb/lib/src/pubspec.dart#L64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants