Skip to content

Commit

Permalink
Don’t update Package.resolved from sourcekit-lsp
Browse files Browse the repository at this point in the history
`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 apple#707
rdar://105173375
  • Loading branch information
ahoppen committed Jul 7, 2023
1 parent af5cd53 commit 531f8a9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift
Expand Up @@ -177,6 +177,7 @@ extension SwiftPMWorkspace {

let packageGraph = try self.workspace.loadPackageGraph(
rootInput: PackageGraphRootInput(packages: [packageRoot]),
forceResolvedVersions: true,
observabilityScope: observabilitySystem.topScope
)

Expand Down

0 comments on commit 531f8a9

Please sign in to comment.