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

Fix "build" for already installed ports. #492

Merged
merged 9 commits into from
Apr 12, 2022

Conversation

BillyONeal
Copy link
Member

Resolves microsoft/vcpkg#13933

Rather than attempting to deal with the condition that the plan created thinks the thing we want to build is already installed, this version just "removes" the thing we want to build from the in-memory status database before creating the plan.

Resolves microsoft/vcpkg#13933

Rather than attempting to deal with the condition that the plan created thinks the thing we want to build is already installed, this version just "removes" the thing we want to build from the in-memory status database before creating the plan.
@ras0219-msft
Copy link
Contributor

Rebuilding a package that's currently installed is insanely suspect, because the headers are very likely to collide with each other and produce weird results if they are different.

I think a better approach here is to improve the error message from "Value was null" to "zlib:x64-windows is currently installed. You must remove zlib:x64-windows before building.".

@BillyONeal
Copy link
Member Author

@@ -3,9 +3,9 @@ Computing installation plan...
 The following packages will be built and installed:
     vcpkg-hello-world-1[core]:x86-windows -> 0 -- C:\Dev\vcpkg-tool\azure-pipelines\e2e_ports\overlays\vcpkg-hello-world-1
 Detecting compiler hash for triplet x86-windows...
-Restored 0 packages from C:\Users\billy\AppData\Local\vcpkg\archives in 119.6 us. Use --debug to see more details.
-Starting package 1/1: vcpkg-hello-world-1:x86-windows
-Building package vcpkg-hello-world-1[core]:x86-windows...
+Restored 0 packages from C:\Users\billy\AppData\Local\vcpkg\archives in 399.2 us. Use --debug to see more details.
+Installing vcpkg-hello-world-1:x86-windows... (1/1)...
+Building vcpkg-hello-world-1[core]:x86-windows...
 -- Installing port from location: C:\Dev\vcpkg-tool\azure-pipelines\e2e_ports\overlays\vcpkg-hello-world-1
 -- Found external ninja('1.10.2').
 -- Configuring x86-windows
@@ -24,15 +24,11 @@ Call Stack (most recent call first):
 
 
 error: building vcpkg-hello-world-1:x86-windows failed with: BUILD_FAILED
-Please ensure you're using the latest portfiles with `git pull` and `.\vcpkg update`.
+Please ensure you're using the latest port files 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+vcpkg-hello-world-1
+    https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+vcpkg-hello-world-1
 You can submit a new issue at:
-  https://github.com/microsoft/vcpkg/issues/new?template=report-package-build-failure.md&title=[vcpkg-hello-world-1]+Build+error
-including:
-  package: vcpkg-hello-world-1[core]:x86-windows -> 0
-    vcpkg-tool version: 2022-03-30-692785ac944e81417840c6de244fb3e18a4b35eb
+    https://github.com/microsoft/vcpkg/issues/new?template=report-package-build-failure.md&title=[vcpkg-hello-world-1]+Build+error
+Include '[vcpkg-hello-world-1] Build error' in your bug report title, the following version information in your bug description, and attach any relevant failure logs from above.
+    vcpkg-tool version: 2999-12-31-unknownhash-debug
     vcpkg-scripts version: d72783cb3 2022-04-07 (28 hours ago)
-
-Additionally, attach any relevant sections from the log files above.

@BillyONeal
Copy link
Member Author

image

@BillyONeal BillyONeal requested a review from strega-nil-ms April 9, 2022 00:40
src/vcpkg/build.cpp Outdated Show resolved Hide resolved
src/vcpkg/build.cpp Outdated Show resolved Hide resolved
const auto port_name = spec.package_spec.name();
const auto* scfl = provider.get_control_file(port_name).get();

Checks::check_maybe_upgrade(VCPKG_LINE_INFO, scfl != nullptr, "Error: Couldn't find port '%s'", port_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this PR is removing this error message, have you checked that the new error message along this path is still reasonable?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this error message was unreachable:

image

Comment on lines 1051 to +1053
if (!fs.exists(buildpath, IgnoreErrors{}))
{
std::error_code err;
fs.create_directory(buildpath, err);
Checks::check_exit(
VCPKG_LINE_INFO, !err.value(), "Failed to create directory '%s', code: %d", buildpath, err.value());
fs.create_directory(buildpath, VCPKG_LINE_INFO);
Copy link
Contributor

Choose a reason for hiding this comment

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

As usual, this TOCTOU-esque pattern is unfortunate. It would be nice to have a simple fs.ensure_directory(buildpath, VCPKG_LINE_INFO) that does the Right Thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm pretty sure create_directory already is that Right Thing (it isn't supposed to fail for existing directories) but doing that debugging seemed out of scope for this change.

@BillyONeal BillyONeal merged commit 52dc46e into microsoft:main Apr 12, 2022
@BillyONeal BillyONeal deleted the value-was-null branch May 23, 2022 22:49
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.

vcpkg build applied to an already-installed port always prints: "Value was null"
4 participants