vknabel/vscode-apple-swift-format

Report Command failed: /usr/local/bin/swift-formatUnable to format /<stdin>: SwiftSyntax parser library isn't compatible

erf opened this issue · 4 comments

erf commented
Error: Command failed: /usr/local/bin/swift-format
Unable to format /<stdin>: SwiftSyntax parser library isn't compatible

	at checkExecSyncError (child_process.js:630:11)
	at Object.execFileSync (child_process.js:648:15)
	at Object.func [as execFileSync] (electron/js2c/asar.js:140:31)
	at format (/Users/erlend/.vscode/extensions/vknabel.vscode-apple-swift-format-1.1.0/out/src/SwiftFormatEditProvider.js:34:40)
	at SwiftFormatEditProvider.provideDocumentFormattingEdits (/Users/erlend/.vscode/extensions/vknabel.vscode-apple-swift-format-1.1.0/out/src/SwiftFormatEditProvider.js:61:16)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:718:265
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:52:373
	at new Promise (<anonymous>)
	at Object.t.asPromise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:52:345)
	at T.provideDocumentFormattingEdits (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:718:236)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:738:230
	at K._withAdapter (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:732:331)
	at K.$provideDocumentFormattingEdits (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:738:208)
	at g._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:860:464)
	at g._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:860:156)
	at g._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:858:766)
	at g._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:857:623)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:855:691
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:256:381)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1047:649
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
	at v.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:256:381)
	at t.PersistentProtocol._receiveMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:261:451)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:258:489
	at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
	at p.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:253:851)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:253:203
	at Socket.t (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:263:54)
	at Socket.emit (events.js:223:5)
	at addChunk (_stream_readable.js:309:12)
	at readableAddChunk (_stream_readable.js:290:11)
	at Socket.Readable.push (_stream_readable.js:224:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:181:23)

Hi @erf!

It seems like your swift-format does not fit together with your currently active Swift version.

E.g. if you are using Swift 5.1 you need to apple/swift-format@swift-5.1-branch. Though for Swift 5.3 use apple/swift-format@swift-5.3-branch.

Keeping this open to improve the error message.

erf commented

@vknabel Ah, i missed that. Feel free to close this.

@erf no worries, a better error message isn't much effort. And I guess this error is too common to present a stacktrace.

Even a simple info to upgrade the formatter would be valuable.

Improvements released in 1.1.1