Skip to content

Fix registry resolution of major alternate package manifests #8188

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

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

fortmarek
Copy link
Contributor

Motivation:

Let's take the following Package.swift:

// swift-tools-version: 5.7

import PackageDescription

let package = Package(
    name: "Library",
    dependencies: [
        .package(id: "AliSoftware.OHHTTPStubs", exact: "9.0.0")
    ]
)

You can find the OHHTTPStubs dependency at that version here.

The dependency has two manifests:

  • Package.swift with swift-tools-version at 4.0
  • [email protected] with swift-tools-version at 5.0

When resolving packages via the registry, SwiftPM should use the [email protected]. However, instead SwiftPM fails with:

Running resolver because the following dependencies were added: 'AliSoftware.OHHTTPStubs' (AliSoftware.OHHTTPStubs)
Computing version for AliSoftware.OHHTTPStubs
info: 'AliSoftware.OHHTTPStubs': retrieving AliSoftware.OHHTTPStubs metadata from http://localhost:8080/api/accounts/tuist/registry/swift/AliSoftware/OHHTTPStubs
info: 'AliSoftware.OHHTTPStubs': retrieving AliSoftware.OHHTTPStubs 9.0.0 metadata from http://localhost:8080/api/accounts/tuist/registry/swift/AliSoftware/OHHTTPStubs/9.0.0
info: 'AliSoftware.OHHTTPStubs': retrieving available manifests for AliSoftware.OHHTTPStubs 9.0.0 from http://localhost:8080/api/accounts/tuist/registry/swift/AliSoftware/OHHTTPStubs/9.0.0/Package.swift
info: 'AliSoftware.OHHTTPStubs': retrieving AliSoftware.OHHTTPStubs 9.0.0 metadata from http://localhost:8080/api/accounts/tuist/registry/swift/AliSoftware/OHHTTPStubs/9.0.0
info: 'AliSoftware.OHHTTPStubs': retrieving AliSoftware.OHHTTPStubs 9.0.0 manifest from http://localhost:8080/api/accounts/tuist/registry/swift/AliSoftware/OHHTTPStubs/9.0.0/Package.swift?swift-version=5.0.0
error: failed locating placeholder manifest for 5.0.0

Modifications:

The reason for the error is because when looking up the alternate package manifests from the downloaded source archive, SwiftPM doesn't try to find [email protected] – only [email protected] and [email protected].

When both minor and patch versions of the swift tools version are 0, SwiftPM should try to use the [email protected] alternate manifest.

Result:

[After your change, what will change.]

swift package resolve will work for packages in a registry that have alternate manifests in the format of [email protected].

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov MaxDesiatov added bug package manifests changes to package manifest APIs registry SwiftPM Registry-related changes dependency resolution labels Dec 23, 2024
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) January 2, 2025 11:40
@MaxDesiatov MaxDesiatov merged commit adf64d4 into swiftlang:main Jan 2, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependency resolution package manifests changes to package manifest APIs registry SwiftPM Registry-related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants