Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace collision with third party library #3086

Closed
nashysolutions opened this issue Oct 14, 2023 · 6 comments
Closed

Namespace collision with third party library #3086

nashysolutions opened this issue Oct 14, 2023 · 6 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@nashysolutions
Copy link

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

@nashysolutions nashysolutions added the bug Something isn't working label Oct 14, 2023
@gwynne gwynne added the invalid This doesn't seem right label Oct 14, 2023
@gwynne
Copy link
Member

gwynne commented Oct 14, 2023

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.

@gwynne gwynne closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2023
@gwynne
Copy link
Member

gwynne commented Oct 14, 2023

@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.

@nashysolutions
Copy link
Author

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.

@gwynne
Copy link
Member

gwynne commented Oct 14, 2023

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"),

😅

@mbrandonw
Copy link

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.

@gwynne
Copy link
Member

gwynne commented Oct 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants