fix(sourcekit-lsp): restore compatibility with sourcekit-lsp 6.3+#4
Open
SandorDobi wants to merge 4 commits into
Open
fix(sourcekit-lsp): restore compatibility with sourcekit-lsp 6.3+#4SandorDobi wants to merge 4 commits into
SandorDobi wants to merge 4 commits into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ()
Stopped overriding environment variable ()
Replaced removed detection (, )
sourcekit-lsp --versionplease? swiftlang/sourcekit-lsp#1830).Target: arm64-apple-macosx26.0 and extracts a concise version string.
Added
Tests
Added 4 new unit tests in :
Verification
[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' 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)
SourceKit-LSP: unknown correctly reports
Checklist