Discussion:
[dart-misc] Is there a reliable way to detect if `pub get` needs running?
Danny Tuppeny
2016-09-04 11:24:33 UTC
Permalink
When opening a Dart project in Dart Code, I'd like to prompt the user and
offer to run `pub get` if things are out of date (eg. you've cloned a new
repo).

Is there a reliable method for me to check whether or not `pub get` is
required? I was going to check for presence of `.packages` and compare
timestamps with `pubspec.yaml` but I don't think they'd be entirely
reliable (shouldn't be bad, but if there's a better way I can do this, I'd
rather just do that instead).
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Natalie Weizenbaum' via Dart Misc
2016-09-04 13:12:54 UTC
Permalink
Nothing more reliable than just running "pub get". Pub has some logic for
this, but there's no way to access it on its own.
Post by Danny Tuppeny
When opening a Dart project in Dart Code, I'd like to prompt the user and
offer to run `pub get` if things are out of date (eg. you've cloned a new
repo).
Is there a reliable method for me to check whether or not `pub get` is
required? I was going to check for presence of `.packages` and compare
timestamps with `pubspec.yaml` but I don't think they'd be entirely
reliable (shouldn't be bad, but if there's a better way I can do this, I'd
rather just do that instead).
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-09-04 13:33:27 UTC
Permalink
Would it be a reasonable thing to do to run "pub get" upon load of a Dart
project? I was hoping to just alert the user ("Your packages are out of
date [run pub get]") but I don't really know a) whether pub get can be
destructive b) it can be slow when doing nothing?



On Sun, 4 Sep 2016 at 14:12 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
Nothing more reliable than just running "pub get". Pub has some logic for
this, but there's no way to access it on its own.
Post by Danny Tuppeny
When opening a Dart project in Dart Code, I'd like to prompt the user and
offer to run `pub get` if things are out of date (eg. you've cloned a new
repo).
Is there a reliable method for me to check whether or not `pub get` is
required? I was going to check for presence of `.packages` and compare
timestamps with `pubspec.yaml` but I don't think they'd be entirely
reliable (shouldn't be bad, but if there's a better way I can do this, I'd
rather just do that instead).
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Natalie Weizenbaum' via Dart Misc
2016-09-04 14:23:42 UTC
Permalink
I'd generally suggest leaving towards encouraging users to run "pub get"
manually. Feel free to file an issue requesting a way to check if a run is
needed.
Post by Danny Tuppeny
Would it be a reasonable thing to do to run "pub get" upon load of a Dart
project? I was hoping to just alert the user ("Your packages are out of
date [run pub get]") but I don't really know a) whether pub get can be
destructive b) it can be slow when doing nothing?
On Sun, 4 Sep 2016 at 14:12 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
Nothing more reliable than just running "pub get". Pub has some logic for
this, but there's no way to access it on its own.
Post by Danny Tuppeny
When opening a Dart project in Dart Code, I'd like to prompt the user
and offer to run `pub get` if things are out of date (eg. you've cloned a
new repo).
Is there a reliable method for me to check whether or not `pub get` is
required? I was going to check for presence of `.packages` and compare
timestamps with `pubspec.yaml` but I don't think they'd be entirely
reliable (shouldn't be bad, but if there's a better way I can do this, I'd
rather just do that instead).
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-09-04 15:27:04 UTC
Permalink
Raised here: https://github.com/dart-lang/pub/issues/1447

In the meantime I might just leave it without a prompt - I guess if no
other IDEs are prompting, Dart devs are probably used to having to run pub
get on a fresh clone/update to avoid getting loads of errors?

Thanks!

On Sun, 4 Sep 2016 at 15:23 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
I'd generally suggest leaving towards encouraging users to run "pub get"
manually. Feel free to file an issue requesting a way to check if a run is
needed.
Post by Danny Tuppeny
Would it be a reasonable thing to do to run "pub get" upon load of a Dart
project? I was hoping to just alert the user ("Your packages are out of
date [run pub get]") but I don't really know a) whether pub get can be
destructive b) it can be slow when doing nothing?
On Sun, 4 Sep 2016 at 14:12 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
Nothing more reliable than just running "pub get". Pub has some logic
for this, but there's no way to access it on its own.
Post by Danny Tuppeny
When opening a Dart project in Dart Code, I'd like to prompt the user
and offer to run `pub get` if things are out of date (eg. you've cloned a
new repo).
Is there a reliable method for me to check whether or not `pub get` is
required? I was going to check for presence of `.packages` and compare
timestamps with `pubspec.yaml` but I don't think they'd be entirely
reliable (shouldn't be bad, but if there's a better way I can do this, I'd
rather just do that instead).
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Michael Thomsen' via Dart Misc
2016-09-05 07:00:42 UTC
Permalink
Some other Dart IDEs prompt at least in the initial case where when opening
a new project for the first time they detect that 'pub get' has never been
run. That also at least tells new users about the existence of pub.
Post by Danny Tuppeny
Raised here: https://github.com/dart-lang/pub/issues/1447
In the meantime I might just leave it without a prompt - I guess if no
other IDEs are prompting, Dart devs are probably used to having to run pub
get on a fresh clone/update to avoid getting loads of errors?
Thanks!
On Sun, 4 Sep 2016 at 15:23 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
I'd generally suggest leaving towards encouraging users to run "pub get"
manually. Feel free to file an issue requesting a way to check if a run is
needed.
Post by Danny Tuppeny
Would it be a reasonable thing to do to run "pub get" upon load of a
Dart project? I was hoping to just alert the user ("Your packages are out
of date [run pub get]") but I don't really know a) whether pub get can be
destructive b) it can be slow when doing nothing?
On Sun, 4 Sep 2016 at 14:12 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
Nothing more reliable than just running "pub get". Pub has some logic
for this, but there's no way to access it on its own.
Post by Danny Tuppeny
When opening a Dart project in Dart Code, I'd like to prompt the user
and offer to run `pub get` if things are out of date (eg. you've cloned a
new repo).
Is there a reliable method for me to check whether or not `pub get` is
required? I was going to check for presence of `.packages` and compare
timestamps with `pubspec.yaml` but I don't think they'd be entirely
reliable (shouldn't be bad, but if there's a better way I can do this, I'd
rather just do that instead).
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Danny Tuppeny
2016-09-05 17:01:21 UTC
Permalink
On Mon, 5 Sep 2016 at 08:01 'Michael Thomsen' via Dart Misc <
Post by 'Michael Thomsen' via Dart Misc
Some other Dart IDEs prompt at least in the initial case where when
opening a new project for the first time they detect that 'pub get' has
never been run. That also at least tells new users about the existence of
pub.
Detecting that there's no packages folder (or .packages file) is probably a
reasonable start, but it won't help in the case where you're part of a team
and you pull updates that included pubspec changes (and now you need to pub
get). If any existing IDEs are doing that, I'd be interested to know to see
if I can figure out what they're doing!
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Matthew Butler
2016-09-08 18:38:59 UTC
Permalink
The most basic solution I can think of is to look at pubspec.lock. If it's
older than pubspec.yaml then you need to run pub get.
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
Günter Zöchbauer
2016-09-09 07:47:01 UTC
Permalink
That's a bit cumbersome when you experiment for example with transformers,
because then the IDE would ask you to run `pub get` / `pub upgrade` after
every change to a transformer setting.
`pub serve` did this a while ago but that was changed. I think they added a
check if the dependencies in `pubspec.yaml` still match the actually
fetched versions in `pubspec.lock` (or something along those lines)
Post by Matthew Butler
The most basic solution I can think of is to look at pubspec.lock. If it's
older than pubspec.yaml then you need to run pub get.
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
Danny Tuppeny
2016-09-09 17:26:04 UTC
Permalink
Post by Günter Zöchbauer
That's a bit cumbersome when you experiment for example with transformers,
because then the IDE would ask you to run `pub get` / `pub upgrade` after
every change to a transformer setting.
Currently I'm just running "pub get" (no prompt) on every save of pubspec
(you can disable this). I figured it would be really fast if it wasn't
doing anything (I presume it doesn't need to go to the network, only
compare .packages and pubspec?). If this isn't the case, maybe I'll have to
do something better (so I'm interested in feedback if anyone is using Dart
Code and seeing this!).

The case this definitely doesn't handle is a colleague updating pubspec and
I pull changes, or I just cloned a fresh project. I think presence of
.packages file and timestamp comparison might handle this but obviously if
pub had something built in I could get it right every time.

I might have a crack at the timestamps if I run out of other things for v1
and there's no native option and see how it feels. I can always ship it
with behind a flag (off by default) and try and get some feedback.
Unfortunately I don't have any real Dart projects (certainly not with
multiple devs) so my real world experience of this is limited! ;-(
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
'Bob Nystrom' via Dart Misc
2016-09-09 20:13:09 UTC
Permalink
I figured it would be really fast if it wasn't doing anything (I presume
it doesn't need to go to the network, only compare .packages and pubspec?).
Yes, in general.

The interesting case is if you have path dependencies onto other local
packages. In that case, it has to check *their* pubspecs too.

Cheers!

– bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
Continue reading on narkive:
Loading...