Skip to content

Commit 64b664d

Browse files
committed
PackageLoading: anchor relative paths for Windows
We currently cannot use `..` as a header search path for Windows even though it may be contained within the package root. This is due to the fact that the path itself was unanchored, and a raw `..` would be treated as the drive root which will almost always be outside of the package root. Construct the absolute path relative to the target root rather than appending, permitting us to form a well-formed path which can be checked for ancestry.
1 parent 995375c commit 64b664d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/PackageLoading/PackageBuilder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,9 +1036,9 @@ public final class PackageBuilder {
10361036
}
10371037

10381038
// Ensure that the search path is contained within the package.
1039-
let subpath = try RelativePath(validating: value)
1040-
guard targetRoot.appending(subpath).isDescendantOfOrEqual(to: self.packagePath) else {
1041-
throw ModuleError.invalidHeaderSearchPath(subpath.pathString)
1039+
let path = try AbsolutePath(value, relativeTo: targetRoot)
1040+
guard path.isDescendantOfOrEqual(to: self.packagePath) else {
1041+
throw ModuleError.invalidHeaderSearchPath(value)
10421042
}
10431043

10441044
case .define(let value):

0 commit comments

Comments
 (0)