Skip to content

fix(sourcekit-lsp): restore compatibility with sourcekit-lsp 6.3+#4

Open
SandorDobi wants to merge 4 commits into
SwiftedMind:mainfrom
SandorDobi:fix/sourcekit-lsp-compat
Open

fix(sourcekit-lsp): restore compatibility with sourcekit-lsp 6.3+#4
SandorDobi wants to merge 4 commits into
SwiftedMind:mainfrom
SandorDobi:fix/sourcekit-lsp-compat

Conversation

@SandorDobi
Copy link
Copy Markdown

Summary

This PR fixes compatibility issues with newer sourcekit-lsp versions (Swift 6.3+). The upstream sourcekit-lsp project removed the flag and deprecated in favor of , which caused monocle to misbehave on recent toolchains.

Changes

Fixed

  • Removed deprecated argument ()

    • In sourcekit-lsp 6.3+, is deprecated and aliases .
    • Passing both caused to override because swift-argument-parser uses the last value for duplicate options.
  • Stopped overriding environment variable ()

    • Setting for SwiftPM workspaces was a hack that broke git config discovery, SSH key resolution, and SwiftPM global configuration.
    • Build directories are now correctly controlled via .
  • Replaced removed detection (, )

Added

  • Compilation database workspace support
    • New for projects using or .
    • auto-detects these files during workspace discovery.
    • routes them to .
    • Updated all exhaustive statements across the codebase (, , ).

Tests

  • Added 4 new unit tests in :

  • All existing tests continue to pass.

Verification

  • [0/1] Planning build
    [1/1] Compiling plugin GenerateManual
    [2/2] Compiling plugin GenerateDoccReference
    Building for debugging...
    [2/5] Write swift-version--58304C5D6DBC2206.txt
    Build complete! (3.48s) passes
  • Test Suite 'All tests' started at 2026-04-22 12:18:06.816.
    Test Suite 'All tests' passed at 2026-04-22 12:18:06.817.
    Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
    ◇ Test run started.
    ↳ Testing Library Version: 1743
    ↳ Target Platform: arm64e-apple-macos14.0
    ◇ Suite FileDescriptorIOTests started.
    ◇ Suite PackageCheckoutLocatorTests started.
    ◇ Suite SymbolSearchRankingTests started.
    ◇ Suite WorkspaceLocatorTests started.
    ◇ Suite SourceKitServiceTests started.
    ◇ Test readAllWithoutTimeoutReadsUntilEOF() started.
    ◇ Test swiftPackageWorkspaceListsCheckedOutPackages() started.
    ◇ Test scopeFiltersToProjectResults() started.
    ◇ Test tuistManagedWorkspaceUsesTuistCheckoutsDirectory() started.
    ◇ Test xcodeWorkspaceBuildRootEndingInBuildFindsCheckoutsInParentDirectory() started.
    ◇ Test exactMatchRanksAboveFuzzyResults() started.
    ◇ Test extractsPackageNameFromCheckoutsPath() started.
    ◇ Test xcodeWorkspaceUsesBuildServerBuildRootToFindCheckouts() started.
    ◇ Test readAllWithTimeoutThrowsWhenNoBytesArrive() started.
    ◇ Test explicitCompilationDatabasePathViaFilePathResolver() started.
    ◇ Test autoDetectionPrefersXcodeProjectOverPackageManifest() started.
    ◇ Test xcodeWorkspaceWithoutBuildServerThrowsHelpfulError() started.
    ◇ Test autoDetectionPrefersPackageManifestOverCompilationDatabase() started.
    ◇ Test explicitPackageManifestPathResolvesSwiftPackageWorkspace() started.
    ◇ Test xcodeWorkspaceWithoutBuildServerConfigurationThrowsHelpfulError() started.
    ◇ Test autoDetectionFindsCompilationDatabaseWorkspace() started.
    ◇ Test explicitCompilationDatabasePathResolvesCorrectly() started.
    ✔ Test extractsPackageNameFromCheckoutsPath() passed after 0.001 seconds.
    ✔ Test readAllWithoutTimeoutReadsUntilEOF() passed after 0.001 seconds.
    ✔ Test scopeFiltersToProjectResults() passed after 0.001 seconds.
    ✔ Test exactMatchRanksAboveFuzzyResults() passed after 0.001 seconds.
    ✔ Suite SymbolSearchRankingTests passed after 0.001 seconds.
    ✔ Test xcodeWorkspaceWithoutBuildServerThrowsHelpfulError() passed after 0.002 seconds.
    ✔ Test explicitPackageManifestPathResolvesSwiftPackageWorkspace() passed after 0.005 seconds.
    ✔ Test explicitCompilationDatabasePathResolvesCorrectly() passed after 0.006 seconds.
    ✔ Test explicitCompilationDatabasePathViaFilePathResolver() passed after 0.006 seconds.
    ✔ Test autoDetectionPrefersPackageManifestOverCompilationDatabase() passed after 0.007 seconds.
    ✔ Test autoDetectionFindsCompilationDatabaseWorkspace() passed after 0.011 seconds.
    ✔ Test xcodeWorkspaceWithoutBuildServerConfigurationThrowsHelpfulError() passed after 0.011 seconds.
    ✔ Suite SourceKitServiceTests passed after 0.011 seconds.
    ✔ Test autoDetectionPrefersXcodeProjectOverPackageManifest() passed after 0.012 seconds.
    ✔ Test tuistManagedWorkspaceUsesTuistCheckoutsDirectory() passed after 0.012 seconds.
    ✔ Suite WorkspaceLocatorTests passed after 0.012 seconds.
    ✔ Test swiftPackageWorkspaceListsCheckedOutPackages() passed after 0.012 seconds.
    ✔ Test xcodeWorkspaceBuildRootEndingInBuildFindsCheckoutsInParentDirectory() passed after 0.017 seconds.
    ✔ Test xcodeWorkspaceUsesBuildServerBuildRootToFindCheckouts() passed after 0.020 seconds.
    ✔ Suite PackageCheckoutLocatorTests passed after 0.021 seconds.
    ✔ Test readAllWithTimeoutThrowsWhenNoBytesArrive() passed after 0.200 seconds.
    ✔ Suite FileDescriptorIOTests passed after 0.200 seconds.
    ✔ Test run with 17 tests in 5 suites passed after 0.200 seconds. passes (17 tests, 5 suites)
  • monocle local-dev
    SourceKit-LSP: unknown correctly reports
  • Manual e2e: , , , and commands work on Swift packages
  • Compilation database workspaces are detected and routed correctly

Checklist

  • Atomic commits with conventional commit messages
  • Changelog updated under
  • Tests added for new behavior
  • No breaking changes to existing CLI interface

In sourcekit-lsp 6.3+, --build-path is deprecated and aliases --scratch-path.
Passing both caused .build to override .sourcekit-lsp-scratch because
swift-argument-parser uses the last value for duplicate options.

Also removed the HOME environment variable override for SwiftPM workspaces,
which was a hack that interfered with git config and other tools that rely
on a real home directory.
sourcekit-lsp removed the --version flag (swiftlang/sourcekit-lsp#1830).
 detectSourceKitVersion() now runs swift --version instead and extracts
a concise version string. The method is no longer throws; it returns
"unknown" gracefully on failure.
Monocle now detects workspaces containing compile_commands.json or
compile_flags.txt and routes them to sourcekit-lsp with the correct
--default-workspace-type compilationDatabase flag.

Also updates retry policies, checkout locators, and dependency locators
to handle the new workspace kind consistently.
Adds unit tests for auto-detection and explicit path resolution of
compilation database workspaces (compile_commands.json / compile_flags.txt).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant