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

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

Closed
slightfoot opened this issue May 13, 2023 · 4 comments · Fixed by dart-lang/pub#3921
Closed

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

slightfoot opened this issue May 13, 2023 · 4 comments · Fixed by dart-lang/pub#3921
Labels
area-tools A meta category for issues that should be addressed by tooling (prefer more concrete areas).

Comments

@slightfoot
Copy link
Contributor

slightfoot commented May 13, 2023

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.

@jonasfj
Copy link
Member

jonasfj commented May 15, 2023

There are two changes here:

The impact of (B) is merely that the user have to sign-in again. An annoyance, but keeping credentials out of the PUB_CACHE is probably a good idea. One could imagine someone caching the PUB_CACHE between builds on a CI system.

I don't think we've considered all the impacts of (A). Especially, not around PATH and globally activated packages.

I think (A) should affect users who have been using Dart since before 2.8, but that's also a sizable number of people.

I also lost 15 GB of disk space to the old directory not being deleted,

Hmm, I suppose a warning message that encouraged users to delete the old folder would be fairly harmless.
Even if a user is using both new and old Dart SDKs, they are probably not using something older than Dart 2.8, which would recreated the PUB_CACHE in the old location.

@jonasfj
Copy link
Member

jonasfj commented May 15, 2023

Filed https://dart-review.googlesource.com/c/sdk/+/303321 to update the CHANGELOG.md.

@jonasfj
Copy link
Member

jonasfj commented May 15, 2023

I'm not sure (A) is something we should revert. I could be convinced, but I think that moving the PUB_CACHE to %LOCALAPPDATA% is a good thing. So doing it as part of Dart 3 seems reasonable.

It probably won't affect most users, but if you are using school or corporate system where %APPDATA% is sync'ed between machines, it's probably bad to have your entire pub-cache transferred as part of your user profile.

We could do a notice message encourage users to delete the old pub-cache. That would help users reclaim some disk space :D

@mit-mit
Copy link
Member

mit-mit commented May 15, 2023

Rather than reverting -- which would out is back mid-stream with two different cache locations -- I suggest we implement the suggested warning message that encourages users to delete the old folder, and update path + then cherry pick that.

copybara-service bot pushed a commit that referenced this issue May 15, 2023
See: #52386
Change-Id: I48149aeeea5a78ea2c1d9d7b3b9df8d48ed2310e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303321
Reviewed-by: Alexander Thomas <[email protected]>
Auto-Submit: Jonas Jensen <[email protected]>
Commit-Queue: Jonas Jensen <[email protected]>
@kevmoo kevmoo added the area-tools A meta category for issues that should be addressed by tooling (prefer more concrete areas). label May 15, 2023
parlough added a commit to dart-lang/site-www that referenced this issue May 23, 2023
Context: dart-lang/sdk#52386

---------

Co-authored-by: Anthony Sansone <[email protected]>
Co-authored-by: Parker Lougheed <[email protected]>
copybara-service bot pushed a commit that referenced this issue May 30, 2023
Bump pub to fe6acca8f5a6e48b7da862038e60db68d26e01b2


Changes:
```
> git log --format="%C(auto) %h %s" 3a7dc04..fe6acca
 https://dart.googlesource.com/pub.git/+/fe6acca8 Warn about presence of legacy cache (3921)

```

Diff: https://dart.googlesource.com/pub.git/+/3a7dc04eda4e7c359aed35176658bb2acc264f2e..fe6acca8f5a6e48b7da862038e60db68d26e01b2/
Bug: #52386
Change-Id: I9ba86cbe7e7336bb5db049a7f647e8d81391e681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305981
Commit-Queue: Sigurd Meldgaard <[email protected]>
Reviewed-by: Jonas Jensen <[email protected]>
rmacnak-google pushed a commit to rmacnak-google/site-www that referenced this issue Sep 5, 2023
Context: dart-lang/sdk#52386

---------

Co-authored-by: Anthony Sansone <[email protected]>
Co-authored-by: Parker Lougheed <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-tools A meta category for issues that should be addressed by tooling (prefer more concrete areas).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants