Skip to content

What is the best way to tell whether pub get needs running for a project? #1678

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

Closed
DanTup opened this issue Jul 31, 2017 · 5 comments
Closed
Labels
type-enhancement A request for a change that isn't a bug

Comments

@DanTup
Copy link

DanTup commented Jul 31, 2017

I'd like to detect when a user opens a project in Dart Code that is missing packages (eg. it's a fresh clone and they've never run pub get) and prompt them, with an easy button to do it (since otherwise they'll get a screenfull of errors).

What's the best way to do this? I see that pub get has a --dry-run option, but I don't know if it's safe to use. Eg.:

  • Is it safe to run in any folder (might not be a dart project root, might be a Flutter or Fuchsia project)
  • Can I rely on specific output (it doesn't look like it's designed to be machine parseable - would you consider a flag to make it?)
  • Is it fast, or does it go over the network for things?
@zoechi
Copy link

zoechi commented Aug 1, 2017

I guess one thing is to check if the .packages and pubspec.lock files exists.
pub serve also does a check if dependencies in pubspec.yaml were modified after the last time pub get or pub upgrade were run, but I don't know how they do that exactly.
You could also check the source of the IntelliJ plugin, because they show a hint to update as well when dependencies in pubspec.yaml were updated. Just comparing file dates isn't enough, because requiring to run pub get every time for example transformer settings were modified is too cumbersome.

@DanTup
Copy link
Author

DanTup commented Aug 1, 2017

Ideally I'd like to avoid adding my own logic for this (to avoid it not matching, or needing maintaining) =)

@nex3 nex3 added the type-enhancement A request for a change that isn't a bug label Sep 20, 2017
@DanTup
Copy link
Author

DanTup commented Feb 21, 2018

For now we're chekcing if .packages is missing or older than pubspec.yaml. It's not foolproof but is apparently what IntelliJ does and you can disable it globally, per-workspace or per-folder if you have a project that works in a way that this doesn't work (eg. the SDK repo).

@sigurdm
Copy link
Contributor

sigurdm commented Jan 17, 2023

@DanTup
Did we land on something useful here? Can this issue be closed?

@DanTup
Copy link
Author

DanTup commented Jan 17, 2023

I don't think anything specific has been done here, but there's a similar issue at #1447 that's a bit more specific and has more recent discussion so I don't think we need both.

@DanTup DanTup closed this as completed Jan 17, 2023
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

4 participants