Deleted pubspec.lock regenerates with newer package versions?

160

A coworker clued me in. Deleting and regenerating the pubspec.lock file performs a pub upgrade, which is why the packages are newer. Doing a pub get does not run pub upgrade.

Share:
160
buttonsrtoys
Author by

buttonsrtoys

Updated on January 03, 2023

Comments

  • buttonsrtoys
    buttonsrtoys over 1 year

    To repair our pubspec.lock file during development, I occasionally delete it and run flutter pub get to regenerate it.

    What I'm seeing now is, I run flutter pub get and no changes are made to the pubspec.lock file. But, when I delete pubspec.lock and run flutter pub get, git shows that several updates to our packages in the regenerated pubspec.lock file compared to the one that was deleted.

    We're all on flutter 2.8. I've tested this with 2.8.0 and 2.8.1 and there are slight differences between the two, but they both update a dozen or more packages. Most updates are patches but a few are minor updates.

    Could be something fundamental I'm not understanding about pubspec.lock files? If we're all on the same version of flutter, shouldn't deleting/rebuilding pubspec.lock produce an identical file?