sourcekit-lsp
sourcekit-lsp copied to clipboard
Indexing-while-building shouldn't overwrite Package.resolved
Swift version
No response
Platform
No response
Editor
VSCode/Cursor
Description
SourceKit-LSP should pass --force-resolved-versions when invoking SwiftPM for background indexing. This ensures:
- SourceKit-LSP never writes to
Package.resolved. - Indexing operates against the package state already on disk, which is the correct behavior — indexing should be read-only.
- If packages are out of date, the resolution will fail, which is preferable to silently corrupting the resolved file.
This aligns with the principle that background indexing should be a read-only operation with respect to project state.
Steps to Reproduce
- Configure a Swift package project that requires
--replace-scm-with-registryfor correct dependency resolution. - Set the flag in
.vscode/settings.json:"swift.packageArguments": ["--replace-scm-with-registry"] - Resolve dependencies normally —
Package.resolvedis correct. - Wait for SourceKit-LSP background indexing to trigger a package resolution.
- Observe that
Package.resolvedis overwritten with dependencies resolved without the--replace-scm-with-registryflag.
Logging
No response
Related issue https://github.com/swiftlang/sourcekit-lsp/issues/1877
Seems to also cause https://github.com/swiftlang/swift-package-manager/issues/9924.