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

flutter update-packages does not update version file used by pub #148571

Open
goderbauer opened this issue May 17, 2024 · 0 comments
Open

flutter update-packages does not update version file used by pub #148571

goderbauer opened this issue May 17, 2024 · 0 comments
Assignees
Labels
P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team triaged-tool Triaged by Flutter Tool team

Comments

@goderbauer
Copy link
Member

There are likely other situations where this happens, but this is how I was able to consistently reproduce the problem:

  1. Clone flutter from a fork (it's important that it's cloned from a fork because those are missing tags): git clone git@github.com:goderbauer/flutter.git
  2. Run ./bin/flutter update-packages -v inside the cloned repository and notice it fails because pub cannot determine the current version of the flutter SDK, it incorrectly thinks it is 0.0.0-unknown. This is because the clone from the fork is missing the version tags.
  3. Add the upstream repository (git remote add upstream git@github.com:flutter/flutter.git) and fetch tags (git fetch upstream)
  4. Check that you have all the tags now (git tag)
  5. Run /bin/flutter update-packages -v - unexpectedly it still fails with the same error. 🔥

Surprisingly, the problem goes away when you run flutter doctor. After that, /bin/flutter update-packages -v succeeds.

Speculation of what is going wrong: The pub tool obtains the current version of the flutter SDK from the bin/cache/flutter.version.json file, which is maintained by the flutter tool. The file is created when flutter update-packages is run for the first time in step 2 above. At this point, due to the missing version tags, the version cannot be determined and 0.0.0-unknown is written into that file. After the tags have been fetched, the flutter tool needs to update the version file when update packages is run a second time in step 5 above, but it fails to do that, causing pub to fail again because it still sees the incorrect old version in the version file.

The version file is updated when running flutter doctor, so that subsequent calls to flutter update-packages then pass.

Conclusion: The pub tool relies on the version file to be up-to-date. So, whenever the flutter tool calls out to pub it needs to make sure that the version file is up-to-date to avoid this failure mode.

cc @christopherfujino in case you have additional context.

@goderbauer goderbauer added the team-tool Owned by Flutter Tool team label May 17, 2024
@andrewkolos andrewkolos added P2 Important issues not at the top of the work list triaged-tool Triaged by Flutter Tool team labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list team-tool Owned by Flutter Tool team triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

No branches or pull requests

3 participants