Closed kennethz3 closed 5 years ago
Hi @kennethz3 thanks for your feedback!
What happens if you try to run /usr/local/bin/sourcekite
manually from the terminal?
Does restarting the vscode window solve the issue?
Essentially the error means, that you don’t have any auto completion. Code highlighting isn’t affected, as SDE does not handle it. In most cases the error is either produced by wrong/missing configs or by dynamic libraries linking issues.
Thanks @vknabel!
Reloading/restarting vscode window (and all windows) does not help the issue unfortunately.
When I run /usr/local/bin/sourcekite
it does not print out anything, as if it is listening to further commands.
Could it be there are issues upon make install
or maybe a problem with vs-code extension settings?
That there is no output when executing sourcekite is correct!
What happens if you enter the following request? (you need to include the trailing newline)
$ /usr/local/bin/sourcekite
1
{
key.request: source.request.protocol_version
}
It should respond as follows
1
{
"key.version_major" : 1,
"key.version_minor" : 0
}
Could you dump your VS Code settings?
You're right, the output is just as you described :smiley:
$ /usr/local/bin/sourcekite
1
{
"key.request": source.request.protocol_version
}
yields:
1
{
"key.version_major" : 1,
"key.version_minor" : 0
}
This is everything I have in settings.json:
{
"python.jediEnabled": false,
"python.linting.pylintArgs": [
"--load-plugins=pylint_django"
],
"terminal.integrated.fontSize": 13,
"swift.path.swift_driver_bin": "/home/kenneth/libraries/swift-5.0.2-RELEASE-ubuntu18.04/usr/bin/",
"swift.path.sourcekite": "/usr/local/bin/sourcekite",
}
So sourcekite works as expected!
Regarding your settings.json your swift.path.swift_driver_bin
should point to the swift
-binary directly. Just to be sure, restart after changing your configs.
{
"python.jediEnabled": false,
"python.linting.pylintArgs": [
"--load-plugins=pylint_django"
],
"terminal.integrated.fontSize": 13,
- "swift.path.swift_driver_bin": "/home/kenneth/libraries/swift-5.0.2-RELEASE-ubuntu18.04/usr/bin/",
+ "swift.path.swift_driver_bin": "/home/kenneth/libraries/swift-5.0.2-RELEASE-ubuntu18.04/usr/bin/swift",
"swift.path.sourcekite": "/usr/local/bin/sourcekite",
}
If that doesn't help either, could you temporarily add the following settings, restart vscode, just hover one single variable and paste all output of Swift
below?
"sde.enableTracing.LSPServer": true,
"sde.enableTracing.client": true
Thereafter remove these settings as logging is very verbose and consumes too many resources.
Thank you for your suggestion to modify the setting. Unfortunately it didn't really change the output, but I will still keep the setting pointing to the actual binary.
This is the log when setting those 2 options to true, and hovering over something in the code. The issue seems to have to do with the libsourcekitdInProc.so symlink
Debugger listening on ws://127.0.0.1:6004/f511d978-37c1-4ce1-bc2e-19a30d6de9bd
For help, see: https://nodejs.org/en/docs/inspector
[-->onInitialize ] isTracingOn=[true],
skProtocolProcess=[/usr/local/bin/sourcekite],skProtocolProcessAsShellCmd=[false]
[-->onDidChangeConfiguration]
[-->onDidChangeConfiguration tracing:
swiftDiverBinPath=[/home/kenneth/libraries/swift-5.0.2-RELEASE-ubuntu18.04/usr/bin/swift],
shellPath=[/bin/sh]]
[sourcekite] ***sourcekite initializing with skProtocolProcess at [/usr/local/bin/sourcekite]
[-->SourcekiteResponseHandler constructor done]
[---onDidChangeContent]
[ERROR][1]
[request] {
key.request: source.request.cursorinfo,
key.sourcefile: "/home/kenneth/Documents/swift_projects/first.swift",
key.offset: 1625,
key.compilerargs: ["/home/kenneth/Documents/swift_projects/first.swift","-target","x86_64-unknown-linux"],
key.sourcetext: "class NamedShape {\n var numberOfSides = 0\n var name: String\n\n init(name: String) {\n self.name = name\n }\n\n func simpleDescription() -> String {\n return \"A shape with \\(numberOfSides) sides.\"\n }\n\n}\n\nclass Square: NamedShape {\n var sideLength: Double\n\n init(sideLength: Double, name: String) {\n self.sideLength = sideLength\n super.init(name: name)\n numberOfSides = 4\n }\n\n func area() -> Double {\n return sideLength * sideLength\n }\n\n override func simpleDescription() -> String {\n return \"A sqaure with \\(numberOfSides) sides of length \\(sideLength)\"\n }\n}\n\nclass Circle: NamedShape {\n var radius: Double\n\n init(radius: Double, name: String) {\n self.radius = radius\n super.init(name: name)\n numberOfSides = 1\n }\n\n func area() -> Double {\n return Double.pi * radius * radius\n }\n\n override func simpleDescription() -> String {\n return \"A circle with \\(numberOfSides) sides and radius \\(radius)\"\n }\n\n}\n\nclass EquilateralTriangle: NamedShape {\n var sideLength: Double = 0.0\n\n init(sideLength: Double, name: String) {\n self.sideLength = sideLength\n super.init(name: name)\n numberOfSides = 3\n }\n\n var perimeter: Double {\n get {\n return 3.0 * sideLength\n }\n\n set {\n sideLength = newValue / 3.0\n }\n }\n\n override func simpleDescription() -> String {\n return \"An equilateral triangle with sides of length \\(sideLength).\"\n }\n}\n\nvar triangle = EquilateralTriangle(sideLength: 3.1, name: \"a triangle\")\nprint(triangle.perimeter)\ntriangle.perimeter = 9.9\nprint(triangle.sideLength)\n"
}
[sourcekite] ***stderr***Fatal error: Loading libsourcekitdInProc.so failed: file /home/kenneth/libraries/sourcekite/.build/checkouts/SourceKitten/Source/SourceKittenFramework/library_wrapper.swift, line 39
[sourcekite] [exited] code: null, signal: SIGILL
@vknabel I think we might have fully/partially solved the issue. The symlink was pointing to the correct file, but the symlink itself was not named correctly. I might have erroneously blindly copied the installation instructions
- sudo ln -s /your/swift/usr/lib/libsourcekitdInProc.so /usr/lib/sourcekitdInProc
+ sudo ln -s /your/swift/usr/lib/libsourcekitdInProc.so /usr/lib/sourcekitdInProc.so
So now if I remove
"sde.enableTracing.LSPServer": true,
"sde.enableTracing.client": true
I don't get any logs in the OUTPUT tab, only the init:
Debugger listening on ws://127.0.0.1:6004/1dd57ede-46ee-48cd-a4f1-b4af3366bc5b
For help, see: https://nodejs.org/en/docs/inspector
If I re-enable those two options, my output is as follows, still has issues, but I guess not as severe as before right?
Debugger listening on ws://127.0.0.1:6004/12fb8ba2-ab4e-4d8c-aa95-ee2b39121086
For help, see: https://nodejs.org/en/docs/inspector
[-->onInitialize ] isTracingOn=[true],
skProtocolProcess=[/usr/local/bin/sourcekite],skProtocolProcessAsShellCmd=[false]
[-->onDidChangeConfiguration]
[-->onDidChangeConfiguration tracing:
swiftDiverBinPath=[/home/kenneth/libraries/swift-5.0.2-RELEASE-ubuntu18.04/usr/bin/swift],
shellPath=[/bin/sh]]
[sourcekite] ***sourcekite initializing with skProtocolProcess at [/usr/local/bin/sourcekite]
[-->SourcekiteResponseHandler constructor done]
[---onDidChangeContent]
[ERROR][1]
[request] {
key.request: source.request.cursorinfo,
key.sourcefile: "/home/kenneth/Documents/swift_projects/second.swift",
key.offset: 2,
key.compilerargs: ["/home/kenneth/Documents/swift_projects/first.swift","/home/kenneth/Documents/swift_projects/second.swift","-target","x86_64-unknown-linux"],
key.sourcetext: "print(\"hello world\")"
}
[sourcekite] ***stderr***sourcekit: [1:operator(): 0.0000] did not find primary SourceFilesourcekit: [1:failed: 0.0000] cursor info failed: did not find primary SourceFile
[SourcekiteResponseHandler] 0
{
}
Great to we got a step further! Currently I am mobile and can’t write or test a lot. A brief search suggests that the extension passes wrong arguments (compare with sourcekit-lsp).
Currently you are using two flat Swift files without any Package.swift-file (which is fine and SDE should handle this correctly). If you are using a Swift Package Manager project these arguments will be calculated differently. This might solve your problem.
Once I’ve got time I will have a deeper look.
having the exact same problem =(
Hi @kalkisama and @kennethz3. Sorry for the late response, but I did not have a lot time.
I could fix you issue. Essentially SDE did not pass some global environment variables (like PATH
, ...).
The fix has been released as 2.8.1.
@vknabel it is working now, thanks!
Works. Thanks a lot @vknabel 👍
Same issue with libsourcekitdInProc.so
. Due to a non-root user my workaround is to correctly set PATH
and LD_LIBRARY_PATH
before starting VScode.
If I add the following to ~/.bashrc
and start VScode from console (instead from desktop icon) it works fine:
export PATH="$HOME/swift-tensorflow/usr/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/swift-tensorflow/usr/lib:$LD_LIBRARY_PATH"
OS: Ubuntu 18.04 VS-Code version: 1.37.0 Swift Version: 5.1-dev
Error upon saving:
Request textDocument/completion failed. Message: Request textDocument/completion failed with message: Cannot call write after a stream was destroyed Code: -32603
So I installed the SDE extension and sourcekite thanks to your documentation :smiley:
For SDE I configured _swift.path.swift_driverbin to be the absolute path of ..../usr/bin of Swift for TensorFlow.
I git cloned sourcekite and followed instructions (including commented ones), and executed
make install PREFIX=/usr/local
; and file was saved as /usr/local/bin/sourcekite . I then set the swift.path.sourcekite option to be /usr/local/bin/sourcekite in vs-code.Is this something I can disregard, or will it affect code completion/highlighting abilities? Thank you