Skip to content

feat: Improve error message for duplicate entries in Package.swift #1561

@AttilaTheFun

Description

@AttilaTheFun

I just tried updating to RSPM 1.0.0-rc1 and I'm getting this error when trying to run bazel mod tidy:

logan@Mac app_engine % bazel mod tidy
ERROR: /private/var/tmp/_bazel_logan/a9bff835f203c9cd5cf94c66e6112ec0/external/rules_swift_package_manager+/swiftpkg/bzlmod/swift_deps.bzl:305:41: Traceback (most recent call last):
        File "/private/var/tmp/_bazel_logan/a9bff835f203c9cd5cf94c66e6112ec0/external/rules_swift_package_manager+/swiftpkg/bzlmod/swift_deps.bzl", line 305, column 41, in _swift_deps_impl
                return module_ctx.extension_metadata(
Error in extension_metadata: in root_module_direct_deps: duplicate entry 'swiftpkg_swift_collections'
ERROR: error evaluating module extension @@rules_swift_package_manager+//:extensions.bzl%swift_deps
ERROR: Failed to process 1 extension due to errors.
    Fetching module extension @@rules_swift_package_manager+//:extensions.bzl%swift_deps; starting

There is only a single entry for swiftpkg_swift_collections in MODULE.bazel, and this is the only reference to it in Package.resolved:

    {
      "identity" : "swift-collections",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-collections.git",
      "state" : {
        "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
        "version" : "1.1.4"
      }
    },

Prior to attempting to update to 1.0.0-rc1 I was using e821150 which was a version of my SwiftSettings PR from a few weeks ago. After I rebased it this started breaking.

@cgrindel @luispadron I think given the timing, it's likely this could be the result of one of the swift package registry PRs:
#1318
#1521

My (truncated) Package.swift has:

// swift-tools-version: 5.9

import PackageDescription

let package = Package(
    name: "Packages",
    dependencies: [

        // MARK: GRPC Dependencies

        .package(url: "https://github.com/grpc/grpc-swift-extras", exact: "1.0.0"), // required for reflection client
        .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", exact: "1.0.1"), // compatible with grpc-swift from 2.0.0
        .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", exact: "1.1.0"), // Required by grpc-swift-extras @ 1.0.0
        .package(url: "https://github.com/grpc/grpc-swift.git", exact: "2.1.0"), // Required by grpc-swift-extras @ 2.0.0, grpc-swift-protobuf @ 1.1.0
        .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.3"), // Required by grpc-swift @ 2.1.0
        .package(url: "https://github.com/apple/swift-protobuf.git", from: "1.28.1"), // Required by grpc-swift @ 2.1.0
        .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.3"), // Required by grpc-swift @ 2.1.0
        
        .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), // Required by grpc-swift @ 2.0.0-beta.2
        .package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"),
    ]
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions