Where is Swift Package Manager cache located (Swift 5.7)?
Asked Answered
I

2

30

After retagging a git commit I'm no longer able to fetch the package, because SP Manager uses some cache which I can't find and clean. Getting error:

Revision 30c16cab9c718416fee2191ff2ac0b6f91eeb511 for base remoteSourceControl https://github.com/myUser/myRepo version 1.0.0 does not match previously recorded value

I cleaned all known to me places: local .build folder, SPM caches in Home and Library/Caches folders, DerivedData, removed Package.resolved.
Using Swift 5.7, trying to generate via swift package generate-xcodeproj. Does anyone know where this cache is?

Inebriant answered 28/6, 2022 at 14:11 Comment(0)
B
92

This one solves the issue for me.

rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf ~/Library/org.swift.swiftpm

From https://blog.todosobreios.com/solucionar-problemas-de-swift-pacakge-manager-spm/

Blacktail answered 2/7, 2022 at 12:1 Comment(2)
Thanks, removing ~/Library/org.swift.swiftpm solved the issue, strange place for cache thoughInebriant
removing the entire directory is overkill. You can delete the specific repository fingerprint within security/fingerprints/Szymanski
H
4

It depends on whether you're building via Xcode, or directly via swift build.

Xcode keeps its packages in ~/Library/Developer/Xcode/DerivedData/<your project>/SourcePackages/checkouts/.

SPM keeps them in .build/checkouts of the project folder.

In general, you should never change the commit a version tag points to, for precisely the reasons you experienced. The version numbers form the identity of a package version (not a commit hash, hash of the files, or anything like that). All the systems that are made to work with package rely on the notion that equal version number means they're identical. You're invalidating this assumption, and you'll cause bugs all over. Release a new minor version with your fix, instead.

Hadley answered 28/6, 2022 at 16:29 Comment(2)
I know, thanks, as I said .build, DerivedData folder were checked, the command is provided.Inebriant
@Inebriant you can try searching the root of your file system for some file name ( one that’s unique enough to lower false matches), and see if there another other caches. But really, heed my advice: just make a new version.Hadley

© 2022 - 2024 — McMap. All rights reserved.