Skip to content

Commit 958e29f

Browse files
committed
Fix an error that causes SourceKit-LSP to exit immediately on Windows
For reasons that are completely oblivious to me, `DispatchIO.write`, which is used to write LSP responses to stdout fails with error code 5 on Windows unless we call `AbsolutePath(validating:)` on some URL first.
1 parent 7a06eb0 commit 958e29f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/sourcekit-lsp/SourceKitLSP.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ struct SourceKitLSP: AsyncParsableCommand {
279279
outFD: realStdoutHandle
280280
)
281281

282+
// For reasons that are completely oblivious to me, `DispatchIO.write`, which is used to write LSP responses to
283+
// stdout fails with error code 5 on Windows unless we call `AbsolutePath(validating:)` on some URL first.
284+
_ = try AbsolutePath(validating: Bundle.main.bundlePath)
285+
282286
var inputMirror: FileHandle? = nil
283287
if let inputMirrorDirectory = globalConfigurationOptions.loggingOrDefault.inputMirrorDirectory {
284288
orLog("Setting up input mirror") {

0 commit comments

Comments
 (0)