Skip to content

Indexing-while-building shouldn't overwrite Package.resolved #2602

Description

@nkcsgexi

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

  1. Configure a Swift package project that requires --replace-scm-with-registry for correct dependency resolution.
  2. Set the flag in .vscode/settings.json:
    "swift.packageArguments": ["--replace-scm-with-registry"]
  3. Resolve dependencies normally — Package.resolved is correct.
  4. Wait for SourceKit-LSP background indexing to trigger a package resolution.
  5. Observe that Package.resolved is overwritten with dependencies resolved without the --replace-scm-with-registry flag.

Logging

No response

Activity

  1. added theissue type on Apr 10, 2026
  2. tracymiranda commented on Apr 10, 2026

    @tracymiranda

    Related issue #1877

  3. dschaefer2 commented on Apr 14, 2026

    @dschaefer2
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions