swiftlang/swift-package-manager

Binary Artifact Caching Breaks Dependency Resolution

vpopovyc opened this issue · 0 comments

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI.

Description

Binary targets with URLs longer than FILENAME_MAX will fail to resolve in v5.10.

The root cause is how BT's URL is used as a cache key that later is materialized in the directory name.

https://github.com/apple/swift-package-manager/blob/ad7b5ced3cf3af194c10faf4492a9b927f6222d9/Sources/Workspace/Workspace%2BBinaryArtifacts.swift#L597C1-L630C10

I've tested the version before these changes(v5.9), and the resolution works fine.

If you need a real-world example of long URLs, please consider distribution pipelines that use pre-signed URLs to an AWS S3 bucket.

Expected behavior

The same behaviour as was on v5.9.

Actual behavior

Resolution failed

Steps to reproduce

  1. Create a binary target with the URL that has strlen > 255.
  2. Resolve that package.

Swift Package Manager version/commit hash

5.10

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Darwin Vladyslavs-MBP 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 arm64