Warn on classic mode build failure if version constraints weren't met #494
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds tracking for version constraints in classic mode so that they can be displayed to the user in case of a build failure. While it is by design that classic mode does not force users to rebuild dependencies that are out-of-date, knowing the version constraints is a big help for debugging.
The output could be rough in certain circumstances; it will display every non-identical broken constraint and won't deduplicate 'similar' ones. For example, if the immediate dependencies list contains 3 references to
curl
with constraints>= 2
,>= 2
, and>= 3
, on build failure this would display two messages (one for>= 2
and one for>= 3
). This more complex deduplication is challenging to prove correct because we don't have schema information for installed packages. That said, it seems reasonably pathologic to have multiple non-identical constraints in the same package manifest.Finally, this only displays for
install
commands -- it does not display for any other command (e.g.build
,ci
,x-set-installed
).Diff from e2e test:
[end-to-end-tests.ps1] [1/1] Running suite /workspaces/vcpkg-tool/azure-pipelines/end-to-end-tests-dir/classic-versions.ps1 /workspaces/vcpkg-tool-build/vcpkg --triplet x64-linux --x-buildtrees-root=/workspaces/vcpkg-tool/testing/testing/buildtrees --x-install-root=/workspaces/vcpkg-tool/testing/testing/installed --x-packages-root=/workspaces/vcpkg-tool/testing/testing/packages --overlay-ports=/workspaces/vcpkg-tool/azure-pipelines/e2e_ports/overlays --overlay-triplets=/workspaces/vcpkg-tool/azure-pipelines/e2e_ports/triplets install classic-versions-b Computing installation plan... found constraint violation: warning: dependency classic-versions-a:x64-linux was expected to be at least version 2, but is currently 1. The following packages will be built and installed: * classic-versions-a[core]:x64-linux -> 1 -- /workspaces/vcpkg-tool/azure-pipelines/e2e_ports/overlays/classic-versions-a classic-versions-b[core]:x64-linux -> 1 -- /workspaces/vcpkg-tool/azure-pipelines/e2e_ports/overlays/classic-versions-b Additional packages (*) will be modified to complete this operation. Detecting compiler hash for triplet x64-linux... Restored 1 packages from /workspaces/.cache/vcpkg in 1.506 ms. Use --debug to see more details. Installing classic-versions-a:x64-linux... (1/2)... Elapsed time to handle classic-versions-a:x64-linux: 547.1 us Installing classic-versions-b:x64-linux... (2/2)... Building classic-versions-b[core]:x64-linux... -- Installing port from location: /workspaces/vcpkg-tool/azure-pipelines/e2e_ports/overlays/classic-versions-b CMake Error at /workspaces/vcpkg-tool/azure-pipelines/e2e_ports/overlays/classic-versions-b/portfile.cmake:1 (message): FATAL_ERROR Call Stack (most recent call first): scripts/ports.cmake:145 (include) +warning: dependency classic-versions-a:x64-linux was expected to be at least version 2, but is currently 1. error: building classic-versions-b:x64-linux failed with: BUILD_FAILED Please ensure you're using the latest portfiles with `git pull` and `./vcpkg update`. Then check for known issues at: https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+classic-versions-b You can submit a new issue at: https://github.com/microsoft/vcpkg/issues/new?template=report-package-build-failure.md&title=[classic-versions-b]+Build+error including: package: classic-versions-b[core]:x64-linux -> 1 vcpkg-tool version: 2999-12-31-unknownhash-debug vcpkg-scripts version: 9e46bb072 2022-03-02 (5 weeks ago) Additionally, attach any relevant sections from the log files above.
While implementing this, I identified a regression introduced in #322 where
VersionScheme::String
's were being compared lexographically. I've reverted this to the intended behavior (eithereq
orunk
) and added tests covering this case.