Skip to content

Fix swift package describe for packages with binary artifacts that has a .zip extension. #8809

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

taji-taji
Copy link
Contributor

@taji-taji taji-taji commented Jun 12, 2025

Fix swift package describe for packages with binary artifacts that has a .zip extension.

Motivation:

Fixes #4387

I want to avoid an error when running swift package describe on a package that contains a binary artifact target with a .zip extension.

Modifications:

I modified the Workspace.loadRootPackage(at:observabilityScope:completion) method. Specifically, I updated the logic for local binary targets to also return a BinaryArtifact object when the file extension is .zip.
This change is also based on the comment referenced here.

Result:

When running swift package describe on a package that contains a binary artifact target with a .zip extension, the package description is now output without throwing an error.

@plemarquand
Copy link
Contributor

@swift-ci please test

Copy link
Contributor

@bkhouri bkhouri left a comment

Choose a reason for hiding this comment

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

Thanks for this change. would it be possible to add a test that ensures we don't accidentally re-introduce this issue?

@taji-taji
Copy link
Contributor Author

@bkhouri
Thank you for the feedback.
I have modified the contents of testLoadRootPackageWithBinaryDependencies to include a case where a local .zip binary file exists.
I have confirmed that applying this test to the main branch (which does not include the changes from this PR) reproduces the issue and fails as expected.

8777cd9

Test results on the main branch
Test Suite 'Selected tests' started at 2025-06-24 19:27:23.749.
Test Suite 'SwiftPMPackageTests.xctest' started at 2025-06-24 19:27:23.750.
Test Suite 'WorkspaceTests' started at 2025-06-24 19:27:23.750.
Test Case '-[WorkspaceTests.WorkspaceTests testLoadRootPackageWithBinaryDependencies]' started.
/Users/yutaka/workspace/swift-package-manager/Sources/Workspace/Workspace.swift:1138: error: -[WorkspaceTests.WorkspaceTests testLoadRootPackageWithBinaryDependencies] : failed: caught error: "/tmp/ws/roots/Root/a4.zip does not contain binary artifact"
Test Case '-[WorkspaceTests.WorkspaceTests testLoadRootPackageWithBinaryDependencies]' failed (0.199 seconds).
Test Suite 'WorkspaceTests' failed at 2025-06-24 19:27:23.949.
	 Executed 1 test, with 1 failure (1 unexpected) in 0.199 (0.199) seconds
Test Suite 'SwiftPMPackageTests.xctest' failed at 2025-06-24 19:27:23.949.
	 Executed 1 test, with 1 failure (1 unexpected) in 0.199 (0.199) seconds
Test Suite 'Selected tests' failed at 2025-06-24 19:27:23.949.
	 Executed 1 test, with 1 failure (1 unexpected) in 0.199 (0.200) seconds
Test results on this branch
Test Suite 'Selected tests' started at 2025-06-24 19:58:23.823.
Test Suite 'SwiftPMPackageTests.xctest' started at 2025-06-24 19:58:23.824.
Test Suite 'WorkspaceTests' started at 2025-06-24 19:58:23.824.
Test Case '-[WorkspaceTests.WorkspaceTests testLoadRootPackageWithBinaryDependencies]' started.
Test Case '-[WorkspaceTests.WorkspaceTests testLoadRootPackageWithBinaryDependencies]' passed (0.479 seconds).
Test Suite 'WorkspaceTests' passed at 2025-06-24 19:58:24.302.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.479 (0.479) seconds
Test Suite 'SwiftPMPackageTests.xctest' passed at 2025-06-24 19:58:24.302.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.479 (0.479) seconds
Test Suite 'Selected tests' passed at 2025-06-24 19:58:24.302.
	 Executed 1 test, with 0 failures (0 unexpected) in 0.479 (0.480) seconds

@plemarquand
Copy link
Contributor

@swift-ci please test

@taji-taji taji-taji requested a review from bkhouri June 24, 2025 23:38
@bkhouri
Copy link
Contributor

bkhouri commented Jun 25, 2025

@swift-ci test windows

@taji-taji
Copy link
Contributor Author

The test Swift Test Windows Platform (self hosted) (Swift 6.1) has failed, but I’m not sure what caused it.
Please let me know if there are any next steps I should take to move this PR forward.

@bkhouri
Copy link
Contributor

bkhouri commented Jun 30, 2025

@swift-ci test self hosted windows

@taji-taji
Copy link
Contributor Author

@bkhouri
Thank you for triggering the CI. It looks like all checks have passed, so please continue with the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SR-15243] swift package describe Failing for Package with binary targets
3 participants