[vcpkg] Improve error messages when failing to find a backing port
MODIFY
src/vcpkg/dependencies.cpp
src/vcpkg/dependencies.cpp
@@ -265,12 +265,11 @@ namespace vcpkg::Dependencies
m_port_provider.get_control_file(ipv.spec().name());
if (!maybe_scfl)
- Checks::exit_with_message(VCPKG_LINE_INFO,
- "We could not find a CONTROL file for ",
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO,
+ "We could not find a CONTROL file for '%s'. Please run \"vcpkg remove %s\" and re-attempt.",
ipv.spec().to_string(),
- ". Please run \"vcpkg remove ",
- ipv.spec().to_string(),
- "\" and re-attempt.");
+ ipv.spec().to_string());
return m_graph
.emplace(std::piecewise_construct,
@@ -684,8 +683,8 @@ namespace vcpkg::Dependencies
}
// And it has at least one qualified dependency
- if (paragraph_depends && Util::any_of(*paragraph_depends,
- [](auto&& dep) { return !dep.qualifier.empty(); }))
+ if (paragraph_depends &&
+ Util::any_of(*paragraph_depends, [](auto&& dep) { return !dep.qualifier.empty(); }))
{
// Add it to the next batch run
qualified_dependencies.emplace_back(spec);
@@ -864,9 +863,9 @@ namespace vcpkg::Dependencies
continue;
}
auto&& dep_clust = m_graph->get(fspec.spec());
- const auto& default_features =
- [&]{
- if (dep_clust.m_install_info.has_value()) return dep_clust.m_scfl.source_control_file->core_paragraph->default_features;
+ const auto& default_features = [&] {
+ if (dep_clust.m_install_info.has_value())
+ return dep_clust.m_scfl.source_control_file->core_paragraph->default_features;
if (auto p = dep_clust.m_installed.get()) return p->ipv.core->package.default_features;
Checks::unreachable(VCPKG_LINE_INFO);
}();

MODIFY
src/vcpkg/portfileprovider.cpp
src/vcpkg/portfileprovider.cpp
@@ -85,6 +85,8 @@ namespace vcpkg::PortFileProvider
}
}
+ if (filesystem.exists(ports_dir / spec / "CONTROL"))
+ {
auto found_scf = Paragraphs::try_load_port(filesystem, ports_dir / spec);
if (auto scf = found_scf.get())
{
@@ -95,6 +97,18 @@ namespace vcpkg::PortFileProvider
std::forward_as_tuple(std::move(*scf), ports_dir / spec));
return it.first->second;
}
+ Checks::exit_with_message(VCPKG_LINE_INFO,
+ "Error: Failed to load port from %s: names did not match: '%s' != '%s'",
+ (ports_dir / spec).u8string(),
+ spec,
+ scf->get()->core_paragraph->name);
+ }
+ else
+ {
+ vcpkg::print_error_message(found_scf.error());
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO, "Error: Failed to load port from %s", spec, ports_dir.u8string());
+ }
}
}

[vcpkg] Improve error messages when failing to find a backing port