Skip to content

Issue with Dart pub cache since 3.0 launch on windows #52386

Description

@slightfoot

TLDR; Pub changed its cache directory location on Windows and did not move the data or update the PATH and warn the user.

Example:

# melos exec -- flutter pub get
Can't load Kernel binary: Invalid kernel binary format version.

This is usual behaviour with pub global binaries after upgrade of Dart as the snapshot kernel format for the compiled Dart code has changed. It then recompiles the snapshot and all is well.

However, even after the normal recompilation. The error message persists.
This is because melos re-executes itself and it's executing a previous version. This is not a melos specific issue as it also occurs with other previously installed globally activated binaries.

This is because the pub global cache directory has moved. So new binaries/scripts are being created in the new directory and not the old one. Without any warning to remove the old one from the PATH, or to have those binaries/scripts removed.

Flutter 3.7 / Dart 2.19

C:\Users\<user>\AppData\Roaming\Pub\Cache\bin

Flutter 3.10 / Dart 3.0

C:\Users\<user>\AppData\Local\Pub\Cache\bin

With the directory change without the movement of files from one to the other. I have also "lost" the pub publish credentials for packages as that remains in the old directory.

I also lost 15 GB of disk space to the old directory not being deleted, since there was no deletion policy from the upgrade. Not to mention the re-download of all of the pub packages to the new directory using up bandwith. For me this is not an issue, but for some developers in other situations where they pay for the data they download.

I have now updated my PATH and moved my credentials over and removed the old directory and all is well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-toolsA meta category for issues that should be addressed by tooling (prefer more concrete areas).

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions