From 531f8a9793e02e5d5a982c68a6cb586586650e7a Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Fri, 7 Jul 2023 15:30:39 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20update=20Package.resolved=20fro?= =?UTF-8?q?m=20sourcekit-lsp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `SwiftPMWorkspace.reloadPackage` called `loadPackageGraph`, which causes package resolution and could thus update `Package.resolved`. This caused race conditions when `swift package update` was run from terminal while sourcekit-lsp is running since sourcekit-lsp was notified about the file changes and thus reloaded the pacakge to get build settings for the modified files. Set `forceResolvedVersions` to only resolve packages based on the versions in `Package.resolved`, eliminating this problem. Fixes https://github.com/apple/sourcekit-lsp/issues/707 rdar://105173375 --- Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift b/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift index ae5a96f6a..8f0c60f27 100644 --- a/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift +++ b/Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift @@ -177,6 +177,7 @@ extension SwiftPMWorkspace { let packageGraph = try self.workspace.loadPackageGraph( rootInput: PackageGraphRootInput(packages: [packageRoot]), + forceResolvedVersions: true, observabilityScope: observabilitySystem.topScope )