pub icon indicating copy to clipboard operation
pub copied to clipboard

Bring timestamps of (pubspec.yaml, pubspec.lock, dart_tool/package_config.json) in order even if files are not modified

Open sigurdm opened this issue 5 months ago • 2 comments

@sigurdm actually, I think there is a bug here...

If I modify pubspec.yaml by adding a comment, the timestamp is updated. But pub get bails out and doesn't touch the other files because nothing actually changed. However to the IDE, pubspec.yaml now looks newer than the other files, so we think we need to run pub get.

I don't know if https://github.com/dart-lang/pub/issues/1447 will fix this or if it also just uses the timestamps. But if it does fix it, it still requires all clients to adopt it, so I think it would be best if the timestamps were still made consistent?

Originally posted by @DanTup in #4588

sigurdm avatar Sep 17 '25 13:09 sigurdm

As a workaround for this in Dart-Code (since a fix hitting stable is going to be at least a quarter away and the prompts are annoying), I'm going to touch the pubspec.lock/package_config.json after a successful pub get.

https://github.com/Dart-Code/Dart-Code/pull/5760

This is guarded on a version check for >= Dart 3.7.0, and once this issue gets fixed I'll add an upper bound for the version it's fixed in.

@sigurdm let me know if you have any concerns with this (or think I should do it differently). Thanks!

DanTup avatar Oct 20 '25 14:10 DanTup

I think that should be fine

sigurdm avatar Oct 20 '25 14:10 sigurdm