swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.73k stars 1.34k forks source link

Package resolution fails on first workspace launch and succeeds after a retry #5581

Open kadanes opened 2 years ago

kadanes commented 2 years ago

Description

I work on the Amazon Flex delivery app. We use SPM with over 100 different packages, made by different teams. We have a couple of issues with SPM related to package resolution and build times. We had a discussion with Apple engineers David and Artem during WWDC22 open hour lab. They asked us to open issues with SPM for the issues we are seeing.

Expected behavior

Package resolution should succeed on first attempt when a new workspace is launched.

Actual behavior

Package resolution fails on a random package each time our app workspace is launched. The issue gets resolved after I click on File > Packages > Reset Package Caches / Resolve Package Versions.

Steps to reproduce

For an app with complex dependency graph, launch a fresh workspace and package resolution fails. It will succeed on a retry.

Swift Package Manager version/commit hash

SPM 5.6

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

swift-driver version: 1.45.2 Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
Target: arm64-apple-macosx12.0
Darwin f4d488949cc9.ant.amazon.com 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000 arm64
tomerd commented 2 years ago

@parthv21 could you share the package resolution log when it fails?

kadanes commented 2 years ago

Confirmed that the repository exists at the specified path. Error got resolved after hitting Reset Package Caches

Error while fetching remote repository

file:///path/to/local/copy/PackageName.git/: The repository could not be found. Make sure a valid repository exists at the specified location and try again.
tomerd commented 2 years ago

thanks @parthv21 are the dependences local (file://...) or remote (https://...)? could you share the complete Xcode dependencies resolution log? if you prefer to share that privately you can file through https://feedbackassistant.apple.com/

kadanes commented 2 years ago

@tomerd the dependencies are cached locally so it is a file://... path. I will grab a complete log. I shared the failure logs in my comment above.

jnozzi commented 1 year ago

We just ran into a situation where we were seeing a similar, seemingly intermittent error. We traced it to a machine in our CI environment, which had a Homebrew installation of git that was being killed (sig 9) by the system when called from the package manager. The resolution mentioned here worked. We didn't investigate much further but it seemed the level of logging from the package manager was not sufficient to show what was happening (that the problem was less "couldn't clone because can't find the repo" and more "couldn't clone because git is getting killed").

I think the whole interface between SPM and git could use some more robust logging.