Skip to content

Conversation

@sigurdm
Copy link
Contributor

@sigurdm sigurdm commented Nov 7, 2022

Fixes: #2890

@sigurdm sigurdm requested a review from jonasfj November 7, 2022 16:27

log.message(_output);
if (enforceLockfile && hasChanges) {
dataError('Could not enforce the lockfile.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be better if these error messages mentioned:

  • Resolution aborted: Unable to satisfy pubspec.yaml using the existing pubspec.lock
  • Try without --enforce-lockfile to update pubspec.lock.
  • X number of dependencies changed in pubspec.lock.
  • pubspec.lock does not exist (if that is the case).

Just some ideas for information that should go into this message.


Interesting side note:

It's unclear if we actually should allow resolution to go ahead. I think it's the best implementation for us.
But it leaves the user with weird behavior, where --enforce-lockfile can cause a dependency conflict.
Which should never be possible, because --enforce-lockfile implies that I don't want resolution to be taking place at all.

But I'm not sure we want the number of hacks necessary to work around this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X number of dependencies changed in pubspec.lock.

This is mentioned by the report.summary.

pubspec.lock does not exist (if that is the case).

That case is handled separately before even attempting to resolve.

await report.summarize();
if (enforceLockfile && hasChanges) {
dataError(
'Could not enforce the lockfile$suffix.${onlyReportSuccessOrFailure ? forDetails() : ''}');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, shouldn't this say:

Cannot not enforce pubspec.lock, try dart pub get without --enforce-lockfile to resolve dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The discrepancies will have been output by report.show+summarize at this point.

But adding the suggestions to try without --enforce-lockfile is good.

: ' --directory ${root.dir}';
throw ApplicationException(
'Resolving dependencies$suffix failed. For details run `$topLevelProgram pub ${type.toString()}$directoryOption`');
'Resolving dependencies$suffix failed.${forDetails()}');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think forDetails can be reused out of this flow. So why not move it in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using it also below when the resolution succeeded, but something changed from the pubspec.lock.

sigurdm and others added 2 commits November 14, 2022 10:04
Co-authored-by: Jonas Finnemann Jensen <jopsen@gmail.com>
@sigurdm sigurdm requested a review from jonasfj November 18, 2022 14:38
'enforce-lockfile',
negatable: false,
help:
'Enforce pubspec.lock. Fail resolution if pubspec.lock does not satisfy pubspec.yaml',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Enforce pubspec.lock. Fail resolution if pubspec.lock does not satisfy pubspec.yaml',
'Enforce pubspec.lock, fails resolution if pubspec.lock does not satisfy pubspec.yaml',

Don't know, maybe I'm just crazy -- English is not my first language.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both are valid. Landing as is - we can follow up with a fix if you disagree.

@sigurdm sigurdm merged commit 1acfd4f into dart-lang:master Nov 23, 2022
sigurdm added a commit to sigurdm/pub that referenced this pull request Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dart pub get --pristine/--locked

2 participants