-
Notifications
You must be signed in to change notification settings - Fork 229
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
Add the ability to check if "pub get" needs running #1447
Comments
|
I'm not sure this would work - we can't globally install pub packages on the end-users machine and even if you can write a dart app using this library that reads another projects pubspec, our extension is written in TypeScript and it'd be a bit clunky shipping a dart app inside our TypeScript app (long-term we'd like to be written in Dart, but that's way off and might not be feasible).
We're not planning on upgrading anything - this is a request for detecting when An IDE should be able to detect when the local |
Could this be implemented as
With an exit-code of 0 meaning everything is up-to-date? |
I think so. For now I'm just checking timestamps on Some things to consider:
|
Yeah I think this should be thread safe as it is not writing anything. Btw. 5bda798 should fix the issues with running
Good question. I would think |
So we could run
What about if there are other types of failures (eg. Pub can't be contacted)? Would it be better to have a single exit code that means there definitely are updates and you should run without |
Yeah I think having a specific error code for update-needed would be good. Looking in exit_codes.dart doesn't yield much prior art here. Perhaps exiting with 1 could mean not-up-to-date... |
Grep returns 1 if it found no matches - that seems somehow analogous. |
Isn't that the opposite? Grep returns 1 for nothing found (eg. it failed to do what you want) but here we're talking about signalling there is the thing you were checking for (available updates)? That said, the number isn't so important to me (as a consumer), as long as it's documented and uniquely means I should prompt the user to fetch, so anything you think suitable gets my vote :-) |
@jonasfj probably has an opinion here. |
Doesn't this have to be very fast? Is the overhead of using Also IMO, we should rely on:
This is a very good approximation. Indeed this is the first thing In cases where this invariant doesn't hold, I suggest running In general, I'm not sure we shouldn't just run
For the record,
Checking modification timestamps, and then just running
If |
Yes, I think you're probably right. Really we want something fast that doesn't even touch the network.
This is what I'm doing today, although it's possible pubspec.lock doesn't exist and we shouldn't assume it's safe to run Given the network access in
We do this if the file is modified while the editor is open, but doing it automatically when you open a folder feels a bit aggressive (especially if you consider the user may be offline, and Flutter can easily get into loops like #2242 that never end). I want my editor to open as fast as possible, and it's already starting a bunch of expensive work (like analyzing the project). Although, perhaps there should be an option (currently our option is just to prompt, but we could make it
As an aside - this behaviour has actually tripped me up a few times.. I didn't realise this happened and invoked one of them inside an
I'd prefer to detect this better because of the issue above... If you don't know about the config, you open the SDK, it calls With LSP/DAP, it should be much simpler for additional editors to support Dart, but there are still a bunch of little bits around the edge like that that aren't nicely abstracted. Whether it's worth doing them, I'm not sure - but it's food for thought. Requirements changing across SDK versions is certainly one place where things get tricky, as the tools may need to support multiple SDK versions, whereas tools inside the SDK are always their own SDK version :-) |
I think it's just as likely that the tools will change. If we embedded
Yeah, many subprocesses aren't cheap, the other reason I would suggest checking timestamps.
Fair enough.
So true.
hehe, when there is a
In google3 they could probably choose not to import the
It's hard to detect this. It seems a bit weird to support an |
I don't know of others either, although I assumed that these aren't particularly special - eg. there's nothing to say some other companies are also not using Pub and doing something similar. Although, without a clear convention, I'm not sure there's an expectation that tools like VS Code would know what to do. Based on the above, I'm not certain if it's worth doing anything here. It does feel inconvenient that each editor will need to understand these rules (and handle I haven't had any complaints about VS Code doing the wrong thing in a long time (I presume this only came up recently because of the |
Do we need to do more here? Can we run with just checking timestamps? |
VS Code currently does check timestamps. It works ok, I don't get many complaints (some Googlers have said they see it more often than they expect, although I don't have anything concrete). It's not ideal because it relies on some assumptions about the files pub writes (these assumptions might also be affected by #4022?). It would certainly be nicer if there was some simple API to allow asking Pub to run whatever the correct logic is and give a response. Whether it's worth doing, I'm less sure. |
It occurs to me that the monorepo work being discussed might impact this. Right now the IDE locates all of the projects, checks timestamps of files in each one, and then offers to run It seems like in the monorepo world, we might no longer want to run |
When a user opens a Dart project in Dart Code I'd like to inform them if they need to run
pub get
(with an easy button to do so) to avoid lots of analysis errors opening freshy-cloned/updated projects.Currently there doesn't seem to be a way to detect if local packages are out of date in order to prompt the user (we could try checking timestamps on
.packages
andpubspec.yaml
but it's not very reliable) so it'd be nice if something could be added.(I'm requesting this in
pub
, but I don't know if it might make sense elsewhere; feel free to request I re-raise this insdk
or somewhere if it would be more appropriate there).The text was updated successfully, but these errors were encountered: