swift-package-manager: Couldn’t check out revision: reference is not a tree

Description

Always when we update an own created Swift package that is hosted in our companies git we get the following error in our project cli. After clear the spm cach located at ‘~/builds/cache/spm’ it works

[14:17:18]: ▸     /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies -workspace myworkspace.xcworkspace -scheme myscheme -derivedDataPath ./derivedData -clonedSourcePackagesDirPath "~/builds/cache/spm"
[14:17:18]: ▸ User defaults from command line:
[14:17:18]: ▸     IDEClonedSourcePackagesDirPathOverride = /Users/gitlab-runner/builds/cache/spm
[14:17:18]: ▸     IDEDerivedDataPathOverride = /Users/gitlab-runner/builds/myapp/derivedData
[14:17:18]: ▸     IDEPackageSupportUseBuiltinSCM = YES
[14:17:45]: ▸ xcodebuild: error: Could not resolve package dependencies:
[14:17:45]: ▸   Couldn’t check out revision ‘906c204b2a6f517ccb13ed0c751d3e26013015d0’:
[14:17:45]: ▸     fatal: reference is not a tree: 906c204b2a6f517ccb13ed0c751d3e26013015d0

Expected behavior

Check out the new version of our swift package should be possible without clearing the spm cache

Actual behavior

Error in the pipeline while checkout swift package

[14:17:45]: ▸ xcodebuild: error: Could not resolve package dependencies:
[14:17:45]: ▸   Couldn’t check out revision ‘906c204b2a6f517ccb13ed0c751d3e26013015d0’:
[14:17:45]: ▸     fatal: reference is not a tree: 906c204b2a6f517ccb13ed0c751d3e26013015d0

Steps to reproduce

No response

Swift Package Manager version/commit hash

No response

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

Xcode 14.0 Build version 14A309

swift-driver version: 1.62.8 Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50) Target: arm64-apple-macosx12.0 Darwin static.xx.xx.xx.xx.clients.your-server.de 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 6
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Also seeing this under CI builds, sometimes whenswift-nio gets a new release, the local .build cache is not updated properly and get a failure when swift package update is executed with an error like:

error: 'swift-nio': Couldn’t check out revision ‘9b2848d76f5caad08b97e71a04345aa5bdb23a06’:
    fatal: reference is not a tree: 9b2848d76f5caad08b97e71a04345aa5bdb23a06

The mentioned commit is 2.49 release tag.

Project would have an indirect dependency to something like:

        .package(url: "https://github.com/apple/swift-nio", .upToNextMajor(from: "2.42.0")),

Happens on latest pre-release and 5.7.2:

$ swift --version
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.1 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0

Cleaning the .build directory solves this.