Skip to content

Print reason for requiring resolution in verbose mode #3688

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

Merged
merged 1 commit into from
Sep 2, 2021

Conversation

neonichu
Copy link
Contributor

When running SwiftPM while requiring a resolved file, print some more verbose info on why SwiftPM decided the existing file was out-of-date or why a resolved file was required.

Motivation:

We have been seeing some unexplained issues in CI related to resolved files where this would help us to debug them. It can also generally be helpful for folks.

Modifications:

If resolution is required and we are in verbose mode, append a reason to the diagnostic about the resolved file being out-of-date.

Result:

This is a pretty basic translation from WorkspaceResolveReason into prose which may need some improvements in the future, but it's a start at least.

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

This actually needs an update, I just found that there's an existing mechanism for this willResolveDependencies with already better output.

@neonichu neonichu marked this pull request as draft August 25, 2021 21:31
@abertelrud
Copy link
Contributor

Should this only be for verbose mode? It seems that with this error, it's useful to always know the reason.

@neonichu
Copy link
Contributor Author

@abertelrud I was thinking we only do it in verbose mode initially in case we still want to work on the formatting of the output, but considering this goes to main anyway, maybe that's not necessary.

@abertelrud
Copy link
Contributor

@abertelrud I was thinking we only do it in verbose mode initially in case we still want to work on the formatting of the output, but considering this goes to main anyway, maybe that's not necessary.

I do prefer providing minimal regular information, but in the case of this error, it seems useful to me to have the extra output. Since it's in main we can iterate on it. The alternative is that people have to re-run with verbose mode, and that's suboptimal when looking at CI output (less easy to rerun the command with extra flags).

@neonichu neonichu force-pushed the verbose-requires-resolved-file-message branch from 70262ab to 2265fc5 Compare August 26, 2021 21:32
@neonichu neonichu marked this pull request as ready for review August 26, 2021 21:32
@neonichu
Copy link
Contributor Author

Changed this now by moving the existing code for pretty printing WorkspaceResolveReason and always appending it to the diagnostic here, not just in verbose mode.

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

Ah the existing tests for the diagnostics need an update.

@neonichu
Copy link
Contributor Author

Looks like the values of WorkspaceResolveReason aren't actually stable :/ In testForceResolveWithNoResolvedFile, I would expect both dependencies to show up, but instead just one of them shows up and which one is not deterministic.

@neonichu
Copy link
Contributor Author

So I guess we have two options:

  • change the test so that it checks the prefix of the diagnostic or something like that and live with the non-determinism for now
  • hold off on improving the diagnostic until we can make it deterministic

I'm kind of tending towards option 1, since this seems like a strict improvement even with the non-determinism. What do others think?

@neonichu neonichu self-assigned this Aug 27, 2021
@abertelrud
Copy link
Contributor

It depends on how much effort making it deterministic would be. I usually prefer incremental improvements, since deeper dives sometimes get shelved when more urgent things come along and then nothing has improved. So in that spirit I would go for 1, but it would be great to later try to make it deterministic.

@neonichu
Copy link
Contributor Author

It looks like the problem is that despite the WorkspaceResolveReason carrying a list of dependencies which are new, it'll actually stop resolving after encountering the first missing one. This, together with the fact that this happens during package loading which is done concurrently leads to the non-determinism.

@neonichu neonichu force-pushed the verbose-requires-resolved-file-message branch from 2265fc5 to 89d007a Compare August 30, 2021 20:50
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

Updated this now to go with option 1 and filed a follow-up radar for the non-determinism.

@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Aug 30, 2021
@tomerd
Copy link
Contributor

tomerd commented Aug 31, 2021

@swift-ci smoke test

This moves the existing code for printing a `WorkspaceResolveReason` and always appends it to the diagnostic for an out-of-date required resolved file.
@neonichu neonichu force-pushed the verbose-requires-resolved-file-message branch from 89d007a to a385e62 Compare September 1, 2021 16:55
@neonichu
Copy link
Contributor Author

neonichu commented Sep 1, 2021

@swift-ci smoke test

@neonichu neonichu merged commit dd71675 into main Sep 2, 2021
@neonichu neonichu deleted the verbose-requires-resolved-file-message branch September 2, 2021 03:59
mattt pushed a commit to mattt/swift-package-manager that referenced this pull request Sep 16, 2021
This moves the existing code for printing a `WorkspaceResolveReason` and always appends it to the diagnostic for an out-of-date required resolved file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants