Swift version
swift-driver version: 1.168.6 Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)
Platform
macOS 27.0.1 (26A434)
Editor
IntelliJ IDEA 2026.2 (SourceKit-LSP from Xcode 27.0 (27A266a))
Description
SwiftPMBuildServer.prepare(singleTarget:) runs swift build with workingDirectory: nil, so the build inherits SourceKit-LSP's working directory, which is whatever directory from which the editor launched it:
Any relative path written during preparation therefore lands outside the scratch directory, & possibly outside the package entirely. In practice, swift-driver writes relative supplementary outputs (from the example from swiftlang/swift-package-manager#10652: MAS+BuildInfo-2.d, MAS+BuildInfo-2.dia, MAS+BuildInfo-2.swiftdeps & MAS+BuildInfo-2.swiftmodule) when an input is missing from SwiftPM's output file map.
For mas, these files appeared both in the package root & in an unrelated sibling clone that happened to be SourceKit-LSP's working directory, while the .d files listed sources from the other package.
Running preparation with a working directory inside the scratch directory (e.g., .build/index-build) would confine any such stray outputs to build artifacts.
Steps to Reproduce
- Launch SourceKit-LSP with a working directory other than the package root
- Open a package whose
swift build writes a relative path during preparation (e.g., via the SwiftPM issue above)
- The relative path is resolved against SourceKit-LSP's working directory, not the package or scratch directory
Logging
Not captured; the stray files were found after the fact.
Swift version
swift-driver version: 1.168.6 Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)
Platform
macOS 27.0.1 (26A434)
Editor
IntelliJ IDEA 2026.2 (SourceKit-LSP from Xcode 27.0 (27A266a))
Description
SwiftPMBuildServer.prepare(singleTarget:)runsswift buildwithworkingDirectory: nil, so the build inherits SourceKit-LSP's working directory, which is whatever directory from which the editor launched it:sourcekit-lsp/Sources/BuildServerIntegration/SwiftPMBuildServer.swift
Line 888 in f4be402
Any relative path written during preparation therefore lands outside the scratch directory, & possibly outside the package entirely. In practice, swift-driver writes relative supplementary outputs (from the example from swiftlang/swift-package-manager#10652:
MAS+BuildInfo-2.d,MAS+BuildInfo-2.dia,MAS+BuildInfo-2.swiftdeps&MAS+BuildInfo-2.swiftmodule) when an input is missing from SwiftPM's output file map.For mas, these files appeared both in the package root & in an unrelated sibling clone that happened to be SourceKit-LSP's working directory, while the
.dfiles listed sources from the other package.Running preparation with a working directory inside the scratch directory (e.g.,
.build/index-build) would confine any such stray outputs to build artifacts.Steps to Reproduce
swift buildwrites a relative path during preparation (e.g., via the SwiftPM issue above)Logging
Not captured; the stray files were found after the fact.