flutter update-packages
does not update version file used by pub
#148571
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
There are likely other situations where this happens, but this is how I was able to consistently reproduce the problem:
git clone git@github.com:goderbauer/flutter.git
/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 is0.0.0-unknown
. This is because the clone from the fork is missing the version tags.git remote add upstream git@github.com:flutter/flutter.git
) and fetch tags (git fetch upstream
)git tag
)/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 whenflutter 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 and0.0.0-unknown
is written into that file. After the tags have been fetched, the flutter tool needs to update the version file whenupdate 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 toflutter 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.
The text was updated successfully, but these errors were encountered: