question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prompt to run "pub upgrade" upon opening a package if the SDK versions has changed

See original GitHub issue

When the user upgrades their SDK (a major or minor change, but not patch) there may be new versions of packages that were not available before (or that are required for some classes of changes). We should detect this change when we’re checking if they need to run “pub get” (we can get the last version used to fetch packages from .dart_tool/package_config.json: ("generatorVersion": "2.19.0-374.0.dev")) and offer to run pub upgrade (in preference to pub get).

@devoncarew should we do this in both directions, or only one? It probably doesn’t affect many users, but I realise that I often switch between SDK versions (for testing) and if I click pub upgrade on this prompt and then switch back to an older SDK, there’s a possibility that I now have packages that are not valid. Would pub upgrade even fix this (I don’t thinkpub downgrade is what’s wanted here, because I want to go back to “the highest that is valid given this new (lower) SDK”?)

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Nov 14, 2022

Yeah, the other one said “Get packages”. I’ve changed them to run 'pub get' and run 'pub upgrade' (I left off dart to be shorter and avoid confusion with flutter and this prompt may apply to multiple projects in the workspace), looks like this now (I changed “upgrade” to “updated” in the text as I think it reads a little better too, but happy to tweak):

Screenshot 2022-11-14 at 17 13 04

1reaction
DanTupcommented, Nov 10, 2022

handle it but switch to using pub get?

Ah, I hadn’t considered that that would fix it, that makes sense. So where today it’s:

  • if package_config is missing or timestamped older than pubspec
    • prompt to pub get

I think we probably want:

  • if package_config is missing
    • prompt to pub get
  • else if sdk major/minor version has increased since current package_config
    • prompt to pub upgrade
  • else if package_config is timestamped older than pubspec or sdk major/minor version has decreased
    • prompt to pub get

?

Read more comments on GitHub >

github_iconTop Results From Across the Web

dart pub upgrade
Use dart pub upgrade to get the latest versions of all dependencies used by your Dart app.
Read more >
Unable to 'pub upgrade' flutter tool. · Issue #12666 - GitHub
C:\Users\git>flutter doctor Updating flutter tool... The system cannot find the path specified. Error: Unable to 'pub upgrade' flutter tool.
Read more >
dart - Error: Unable to 'pub upgrade' flutter tool. Retrying in five ...
Run in command line flutter pub cache repair . After that I run flutter doctor and get predictable results: e:\tools>flutter doctor Doctor ...
Read more >
Upgrading - Flutter documentation
This command gets the most recent version of the Flutter SDK that's available on your current Flutter channel. If you want an even...
Read more >
All about the Pub command line tool for Flutter and Dart
flutter pub upgrade --dry-run : This allows you to see what new package versions are available without actually upgrading. However, you might as ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found