Uploaded image for project: 'Swift'
  1. Swift
  2. SR-14464

SwiftPM fails to resolve packages with relative paths on Windows



    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Package Manager
    • Labels:
    • Environment:

      Github actions CI, windows-latest (copied the setup script from compnerd's WinRT demo).

      Swift for Windows DEVELOPMENT-SNAPSHOT-2021-03-25


      I have a package for a library, swift-url. Within its repository, I have a folder "Benchmarks", containing another Swift package. The Package.swift for Benchmarks looks as follows:

      // swift-tools-version:5.3
      import PackageDescription
      let package = Package(
          name: "swift-url-benchmark",
          products: [
              .executable(name: "WebURLBenchmark", targets: ["WebURLBenchmark"])
          dependencies: [
            .package(name: "Benchmark", url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
            .package(name: "swift-url", path: ".."),
          targets: [
              name: "WebURLBenchmark",
              dependencies: [
                .product(name: "WebURL", package: "swift-url"),
                .product(name: "Benchmark", package: "Benchmark")

       Where the "WebURL" product is defined by swift-url's Package.swift.

      swift-url builds, and its tests build, run, and pass on macOS, Linux, and Windows. Benchmarks fails to build on Windows only, and it seems like the issue is the relative path.

      On macOS and Linux, I can build and run WebURLBenchmark even if I omit naming the parent package as "swift-url" in the package dependencies list (just writing `.package(path: "..")`) even if I refer to it by name in the target dependencies. SwiftPM somehow figures it out from the parent folder's name. If I try that on Windows, I get the following error:


      D:\a\swift-url\swift-url\Benchmarks: error: unknown package 'swift-url' in dependencies of target 'WebURLBenchmark'; valid packages are: 'Benchmark', 'D:'
      Error: Process completed with exit code 1.

      "D:" is obviously not my package name. Seems like some path issues. If I add an explicit package name in the package dependencies list (so it looks like the snippet I pasted above), the error becomes:


      Running resolver because the following dependencies were added: 'https://github.com/google/swift-benchmark', 'D:\'
      error: D:\Package.swift has no Package.swift manifest
      Error: Process completed with exit code 1.





            Unassigned Unassigned
            kawa Karl
            0 Vote for this issue
            2 Start watching this issue