Skip to content
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

Overhaul diagnostics in upgrade to not silently ignore parse failures #1486

Closed
wants to merge 16 commits into from

Conversation

BillyONeal
Copy link
Member

In #1473 it was discovered that there were several issues with how vcpkg upgrade works:

  • Structurally, upgrade couldn't tell the difference between a malformed port or a port that totally didn't exist. This meant that parse errors got translated into "not found" which is bad when someone might be editing a port.
  • upgrade was duplicating a lot of the package load functionality that should be handled by the way the rest of the tool handles loading ports from disk.
  • There were no tests for much of the upgrade functionality.

Consider the following before and after results. The crash was already fixed in #1473 but other improvements are here.

Before:

PS D:\vcpkg> Set-EmptyTestPort -Name example -Version 1 -PortsRoot D:\vcpkg\ports
PS D:\vcpkg> .\vcpkg.exe install example
Computing installation plan...
The following packages will be built and installed:
    example:x64-windows@1
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
Restored 1 package(s) from C:\Users\bion\AppData\Local\vcpkg\archives in 55.8 ms. Use --debug to see more details.
Installing 1/1 example:x64-windows@1...
Elapsed time to handle example:x64-windows: 2.2 ms
example:x64-windows package ABI: eb2404a5feb27c3ca35c3362ae7c7eb56390ecfd60374404b7e825339fa7a88e
Total install time: 2.42 ms
PS D:\vcpkg> .\vcpkg.exe upgrade example
The following packages are up-to-date:
  example:x64-windows
PS D:\vcpkg> .\vcpkg.exe upgrade
All installed packages are up-to-date.
PS D:\vcpkg> .\vcpkg.exe upgrade vcpkg-cmake
error: The following packages are not installed:
  vcpkg-cmake:x64-windows
internal error: D:\a\_work\1\s\src\vcpkg\commands.upgrade.cpp(183): vcpkg has crashed; no additional details are available.
Please open an issue at https://github.com/microsoft/vcpkg/issues/new?template=other-type-of-bug-report.md&labels=category:vcpkg-bug with detailed steps to reproduce the problem.
PS D:\vcpkg> Remove-Item D:\vcpkg\ports\example -Recurse -Force
PS D:\vcpkg> .\vcpkg.exe upgrade
All installed packages are up-to-date.
PS D:\vcpkg> .\vcpkg.exe upgrade example
error: The following packages do not have a valid CONTROL or vcpkg.json:
  example:x64-windows
internal error: D:\a\_work\1\s\src\vcpkg\commands.upgrade.cpp(183): vcpkg has crashed; no additional details are available.
Please open an issue at https://github.com/microsoft/vcpkg/issues/new?template=other-type-of-bug-report.md&labels=category:vcpkg-bug with detailed steps to reproduce the problem.
PS D:\vcpkg> Set-EmptyTestPort -Name example -Version 2 -PortsRoot D:\vcpkg\ports
PS D:\vcpkg> Set-EmptyTestPort -Name example-malformed -Version 2 -PortsRoot D:\vcpkg\ports
PS D:\vcpkg> .\vcpkg.exe install example example-malformed --recurse
Computing installation plan...
The following packages are already installed:
    example:x64-windows@1
The following packages will be built and installed:
    example-malformed:x64-windows@2
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\bion\AppData\Local\vcpkg\archives in 98 us. Use --debug to see more details.
example:x64-windows is already installed
Installing 1/1 example-malformed:x64-windows@2...
Building example-malformed:x64-windows@2...
-- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
Stored binaries in 1 destinations in 33 ms.
Elapsed time to handle example-malformed:x64-windows: 85 ms
example-malformed:x64-windows package ABI: a566feeff21f116d018c0b8c231e090eb7e601962cbc1687ca5a3f64cab1500f
Total install time: 85.6 ms
PS D:\vcpkg> Set-EmptyTestPort -Name example-malformed -Version 2 -PortsRoot D:\vcpkg\ports -Malformed
PS D:\vcpkg> .\vcpkg.exe upgrade
The following packages will be rebuilt:
  * example:x64-windows@2
Additional packages (*) will be modified to complete this operation.
If you are sure you want to rebuild the above packages, run this command with the --no-dry-run option.
PS D:\vcpkg> .\vcpkg.exe upgrade example-malformed
error: The following packages do not have a valid CONTROL or vcpkg.json:
  example-malformed:x64-windows
internal error: D:\a\_work\1\s\src\vcpkg\commands.upgrade.cpp(183): vcpkg has crashed; no additional details are available.
Please open an issue at https://github.com/microsoft/vcpkg/issues/new?template=other-type-of-bug-report.md&labels=category:vcpkg-bug with detailed steps to reproduce the problem.

After:

PS D:\vcpkg> Copy-Item D:\vcpkg-tool\out\build\Win-x64-Debug-WithArtifacts\vcpkg.exe vcpkg.exe -force
PS D:\vcpkg> Set-EmptyTestPort -Name example -Version 1 -PortsRoot D:\vcpkg\ports
PS D:\vcpkg> .\vcpkg.exe install example
Computing installation plan...
The following packages will be built and installed:
    example:x64-windows@1
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
Restored 1 package(s) from C:\Users\bion\AppData\Local\vcpkg\archives in 46.3 ms. Use --debug to see more details.
Installing 1/1 example:x64-windows@1...
Elapsed time to handle example:x64-windows: 3.01 ms
example:x64-windows package ABI: eb2404a5feb27c3ca35c3362ae7c7eb56390ecfd60374404b7e825339fa7a88e
Total install time: 3.33 ms
PS D:\vcpkg> .\vcpkg.exe upgrade example
The following packages are up-to-date:
  example:x64-windows@1
All installed packages are up-to-date.
PS D:\vcpkg> .\vcpkg.exe upgrade
The following packages are up-to-date:
  example:x64-windows@1
All installed packages are up-to-date.
PS D:\vcpkg> .\vcpkg.exe upgrade vcpkg-cmake
error: The following explicitly requested upgrades are for packages that are not installed.
  vcpkg-cmake:x64-windows
PS D:\vcpkg> Remove-Item D:\vcpkg\ports\example -Recurse -Force
PS D:\vcpkg> .\vcpkg.exe upgrade
warning: While determining which ports to upgrade, the following parse errors were encountered. Ports with parse errors won't be considered out of date and thus won't be upgraded. To consider these errors in the future, run `vcpkg upgrade` with --`no-keep-going`.
D:\vcpkg\ports\example: error: example does not exist
All installed packages are up-to-date.
PS D:\vcpkg> .\vcpkg.exe upgrade example
D:\vcpkg\ports\example: error: example does not exist
PS D:\vcpkg> Set-EmptyTestPort -Name example -Version 2 -PortsRoot D:\vcpkg\ports
PS D:\vcpkg> Set-EmptyTestPort -Name example-malformed -Version 2 -PortsRoot D:\vcpkg\ports
PS D:\vcpkg> .\vcpkg.exe install example example-malformed --recurse
Computing installation plan...
The following packages are already installed:
    example:x64-windows@1
The following packages will be built and installed:
    example-malformed:x64-windows@2
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
Restored 1 package(s) from C:\Users\bion\AppData\Local\vcpkg\archives in 55.1 ms. Use --debug to see more details.
example:x64-windows is already installed
Installing 1/1 example-malformed:x64-windows@2...
Elapsed time to handle example-malformed:x64-windows: 3.61 ms
example-malformed:x64-windows package ABI: a566feeff21f116d018c0b8c231e090eb7e601962cbc1687ca5a3f64cab1500f
Total install time: 4.07 ms
PS D:\vcpkg> Set-EmptyTestPort -Name example-malformed -Version 2 -PortsRoot D:\vcpkg\ports -Malformed
PS D:\vcpkg> .\vcpkg.exe upgrade
warning: While determining which ports to upgrade, the following parse errors were encountered. Ports with parse errors won't be considered out of date and thus won't be upgraded. To consider these errors in the future, run `vcpkg upgrade` with --`no-keep-going`.
D:\vcpkg\ports\example-malformed\vcpkg.json:3:17: error: Trailing comma in an object
  on expression:   "version": "2",
                                 ^
The following packages will be rebuilt:
  * example:x64-windows@2
Additional packages (*) will be modified to complete this operation.
If you are sure you want to rebuild the above packages, run this command with the --no-dry-run option.
PS D:\vcpkg> .\vcpkg.exe upgrade --no-dry-run
warning: While determining which ports to upgrade, the following parse errors were encountered. Ports with parse errors won't be considered out of date and thus won't be upgraded. To consider these errors in the future, run `vcpkg upgrade` with --`no-keep-going`.
D:\vcpkg\ports\example-malformed\vcpkg.json:3:17: error: Trailing comma in an object
  on expression:   "version": "2",
                                 ^
The following packages will be rebuilt:
  * example:x64-windows@2
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\bion\AppData\Local\vcpkg\archives in 898 us. Use --debug to see more details.
Removing 1/2 example:x64-windows
Elapsed time to handle example:x64-windows: 3.38 ms
Installing 2/2 example:x64-windows@2...
Building example:x64-windows@2...
-- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
Stored binaries in 1 destinations in 75 ms.
Elapsed time to handle example:x64-windows: 131 ms
example:x64-windows package ABI: f1295c003a61ea194816d94d194f5202bd54bfcd7abcf018d6f53c1e732eca8b
Total install time: 135 ms
RESULTS
  example:x64-windows: REMOVED: 3.38 ms
  example:x64-windows: SUCCEEDED: 131 ms

SUMMARY FOR x64-windows
  SUCCEEDED: 1
  REMOVED: 1
PS D:\vcpkg> .\vcpkg.exe upgrade example-malformed
D:\vcpkg\ports\example-malformed\vcpkg.json:3:17: error: Trailing comma in an object
  on expression:   "version": "2",
                                 ^
PS D:\vcpkg>

@BillyONeal
Copy link
Member Author

warning: While determining which ports to upgrade, the following parse errors were encountered. Ports with parse errors won't be considered out of date and thus won't be upgraded. To consider these errors in the future, run `vcpkg upgrade` with --`no-keep-going`.
D:\vcpkg\ports\example: error: example does not exist

Wait I missed this, that's wrong. Stand by...

@BillyONeal BillyONeal marked this pull request as draft September 5, 2024 06:49
@BillyONeal
Copy link
Member Author

The 'hack' I did to make the baseline version not exist doesn't work :(

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.

1 participant