vapor/vapor

Namespace collision with third party library

nashysolutions opened this issue · 6 comments

Describe the bug

Using this package alongside a library from the pointfree team causes a compilation error.

dependencies: [
    .package(url: "git@github.com:vapor/vapor.git", .upToNextMinor(from: "4.0.0")),
    .package(url: "git@github.com:pointfreeco/swift-dependencies.git", .upToNextMinor(from: "1.0.0"))
],

.target(
    name: "MyLibrary",
    dependencies: [
        .product(name: "Vapor", package: "vapor"),
        .product(name: "Dependencies", package: "swift-dependencies")
    ]
)

MyLibrary.zip

To Reproduce

  • open the attached swift package
  • or create your own empty package and specify the above two dependencies.

Expected behavior

The project compiles.

Environment

  • macOS Version 15.0 (15A240d)
  • Xcode Version 15.0 (15A240d)
  • swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
    Target: arm64-apple-macosx14.0

Additional context

Screenshot 2023-10-14 at 16 13 23

This is not a bug in Vapor; the third-party package you're using is polluting the global namespace by aggressively extending the stdlib's protocols and types. This was incorrect, see below for the actual issue.

@nashysolutions Additional information: Your underlying problem here is the misuse of upToNextMinor() with both dependencies. You end up with Vapor 4.0.2, which is quite amazingly ancient (the current version is 4.84.6). Change your dependencies to read:

    .package(url: "git@github.com:vapor/vapor.git", from: "4.0.0"),
    .package(url: "git@github.com:pointfreeco/swift-dependencies.git", from: "1.0.0")
],

With this specification, the build completes without any issue.

I think 4.0.0 was set via the quick start guide vapor new hello -n (at the time). I started my current project about 6 months ago maybe, so it might not be doing that today.
Thanks for your time.

It most definitely is not doing that now - I used that to test your configuration; it generated:

        .package(url: "https://github.com/vapor/vapor.git", from: "4.83.1"),

😅

This is not a bug in Vapor; the third-party package you're using is polluting the global namespace by aggressively extending the stdlib's protocols and types.

@gwynne For the record, our library has nothing to do with this issue. The issue is that compiling a version of Vapor from 3 years ago in Swift 5.9 seems to be exploiting a problem in Swift's split method on Collection and Sequence. There must have been a regression in the standard library / Swift compiler at some point.

This is not a bug in Vapor; the third-party package you're using is polluting the global namespace by aggressively extending the stdlib's protocols and types.

@gwynne For the record, our library has nothing to do with this issue. The issue is that compiling a version of Vapor from 3 years ago in Swift 5.9 seems to be exploiting a problem in Swift's split method on Collection and Sequence. There must have been a regression in the standard library / Swift compiler at some point.

@mbrandonw You're quite correct about your library; my apologies for the misdiagnosis - I've updated my previous comment to reflect this. The problem was entirely due to using such an ancient version of Vapor; 4.0.2 would never have been compatible with Swift 5.9, or even Swift 5.5 for that matter.