dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.04k stars 229 forks source link

`pub get` lockfile-only update #4352

Closed Genora51 closed 2 months ago

Genora51 commented 2 months ago

I'm working on an internal tool which updates pubspec.yaml and then needs to update pubspec.lock. Is there a way to perform this update without fetching hundreds of megabytes of files to disk? That is, is there a way to run pub get to skip the cache and only update the lockfile?

If not, it would be a great feature to have in pub.

sigurdm commented 2 months ago

Currently we don't have such a command.

If resolved packages already exist in the cache they will not be redownloaded.

(well we have something but perhaps not really what you need... https://github.com/dart-lang/pub/blob/19570012d2fc54a18731c83d3c25728fe67d4575/bin/dependency_services.dart is the backing of our dependabot support - it attempts to do updates without downloading packages the tool is described here: https://github.com/dependabot/dependabot-core/blob/7bedcef466a42651f80f5b1a001e45353f4dd38f/pub/README.md You cannot access it directly from the dart sdk - but need to add a git dependency on dartlang-pub... again probably not what you want... )

What is your tool trying to do?

Genora51 commented 2 months ago

dependency_services seems like exactly what I'm looking for! Only problem: on the latest version pub:dependency_services report seems to hang? Or is it just always quite slow and I'm just not letting it run long enough?

sigurdm commented 2 months ago

Only problem: on the latest version pub:dependency_services report seems to hang?

It is waiting for input on stdin. run it like

echo '{}' | dart run pub:dependency_services report

Or if you want to limit the report to a single package run:

echo '{target:"<pgk>"}' | dart run pub:dependency_services report
sigurdm commented 2 months ago

Is this working - do we need more here?

Genora51 commented 2 months ago

Yes it did the trick! Thanks