From d37f8d819fda8f6ee750ddbdb3b551a67e496bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 30 Jun 2020 12:04:29 +0200 Subject: [PATCH] Fix bogus error message for the path used to reference sub packages. Sub packages should ("must") always be referenced through the path of their base package instead of their own path (in case it differs). However, the dependency resolution code assume the opposite. Both way are now accepted, but referencing the sub package path directly results in a warning. --- source/dub/dub.d | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/dub/dub.d b/source/dub/dub.d index 1fee7b968..4f5de9336 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -1588,11 +1588,19 @@ private class DependencyVersionResolver : DependencyResolver!(Dependency, Depend absdeppath.endsWithSlash = true; auto subpack = m_dub.m_packageManager.getSubPackage(basepack, getSubPackageName(d.name), true); if (subpack) { - auto desireddeppath = d.name == dbasename ? basepack.path : subpack.path; + auto desireddeppath = basepack.path; desireddeppath.endsWithSlash = true; - enforce(d.spec.path.empty || absdeppath == desireddeppath, - format("Dependency from %s to root package references wrong path: %s vs. %s", - node.pack, absdeppath.toNativeString(), desireddeppath.toNativeString())); + + auto altdeppath = d.name == dbasename ? basepack.path : subpack.path; + altdeppath.endsWithSlash = true; + + if (absdeppath != desireddeppath) + logWarn("Warning: Sub package %s, referenced by %s %s must be referenced using the path to its base package", + subpack.name, pack.name, pack.version_); + + enforce(d.spec.path.empty || absdeppath == desireddeppath || absdeppath == altdeppath, + format("Dependency from %s to %s uses wrong path: %s vs. %s", + node.pack, subpack.name, absdeppath.toNativeString(), desireddeppath.toNativeString())); } ret ~= TreeNodes(d.name, node.config); continue;