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

Pub should clean up old .packages files. #4370

Open
jakemac53 opened this issue Sep 3, 2024 · 8 comments
Open

Pub should clean up old .packages files. #4370

jakemac53 opened this issue Sep 3, 2024 · 8 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@jakemac53
Copy link
Contributor

Related to dart-lang/package_config#158

I recently ran into an issue when trying the new formatter in a workspace repo. All packages were being parsed with language version 2.7, which was highly confusing. It turns out, there were old .packages files in all the sub-packages, which no longer had a .dart_tool/package_config.json file (it was now one directory up). The presence of these .packages files alone caused a fallback behavior where every package is set to language version 2.7, and they fail to parse new syntax.

I think we should both fix the issue in package_config (so it doesn't support these files at all), as well as have pub clean up any old .packages files it finds - at least when it goes through deleting the .dart_tool/package_config.json files, but maybe just more generally.

@sigurdm
Copy link
Contributor

sigurdm commented Sep 5, 2024

Hmm... we removed all support for .packages, including cleanup some versions ago. Maybe we should reinstate the cleanup...

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Sep 5, 2024
@sigurdm
Copy link
Contributor

sigurdm commented Sep 5, 2024

Not sure this has anything to do with workspaces. Either we clean .packages or we don't. Updating title

@sigurdm sigurdm changed the title Pub workspaces - should clean up old .packages files when removing package config files Pub should clean up old .packages files. Sep 5, 2024
@jakemac53
Copy link
Contributor Author

Not sure this has anything to do with workspaces. Either we clean .packages or we don't. Updating title

It matters in the context of workspaces because when you migrate to them you get broken by the leftover .packages files which now take priority.

@sigurdm
Copy link
Contributor

sigurdm commented Sep 5, 2024

No - leftover .packages anywhere in your project - workspaces or not - will confuse tools that still recognize them.

I think it is rather rare that you migrate from such an old dart sdk that it creates .packages files, and at the same time add workspaces.

That said, I'm not against the idea - I see no reason old .packages files should stay around.

@jakemac53
Copy link
Contributor Author

jakemac53 commented Sep 5, 2024

No - leftover .packages anywhere in your project - workspaces or not - will confuse tools that still recognize them.

The canonical logic (as implemented in package:package_config) will always prefer a .dart_tool/package_config.json file if one exists next to a .packages file. This was very intentionally designed such that the world wouldn't break during the transition.

In my case my .packages files were >2 years old. They just never caused an issue and being hidden files I never noticed them.

@jakemac53
Copy link
Contributor Author

(although, fwiw I did file an issue on package:package_config to stop looking for .packages files by default because I do think that is a bug that it still does respect them)

@sigurdm
Copy link
Contributor

sigurdm commented Sep 5, 2024

files by default because I do think that is a bug that it still does respect them

Yeah, I agree!

@jakemac53
Copy link
Contributor Author

Yeah, I agree!

Feel free to voice your support on dart-lang/package_config#158 haha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants