The Julia VS Code extension installs correctly within Theia. However, when using it, the LanguageServer frequently crashes, due to requests looking like:
[Trace - 10:56:22 AM] Sending request 'julia/getModuleAt - (37)'.
Params: {
"textDocument": {
"uri": "file:///home/project/theia-jl/test.jl"
},
"version": 30,
"position": {
"_line": 11,
"_character": 0
}
}
instead of the expected
[Trace - 10:56:22 AM] Sending request 'julia/getModuleAt - (37)'.
Params: {
"textDocument": {
"uri": "file:///home/project/theia-jl/test.jl"
},
"version": 30,
"position": {
"line": 11,
"character": 0
}
}
In case it would help reproduce the issue, here are the contents of a Dockerfile allowing to build an image in which Julia is installed alongside Theia:
FROM theiaide/theia-full
# Install julia
# /usr/local/bin/julia -> /opt/julia/bin/julia
RUN wget -q -O /tmp/julia.tar.gz \
https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.1-linux-x86_64.tar.gz
RUN cd /opt \
&& sudo tar xvzf /tmp/julia.tar.gz \
&& sudo mv julia-* julia
RUN sudo ln -sf /opt/julia/bin/julia /usr/local/bin/
RUN rm /tmp/julia.tar.gz
I build and use it locally like so:
$ docker build -t theia-jl .
$ docker run -it --init -p 3000:3000 -v "/tmp:/home/project:cached" theia-jl
In such a docker image, the Julia VS code extension should install without any problem, and find the julia binary without any need for specific settings.
And here is an example of Julia source file in case it would help reproducing the issue:
function greet(name="World")
println("Hello $(name)!")
end
greet()
greet("John")
@ffevotte can you reproduce it outside of docker, and preferably on master building from this repository?
Yes, I've been able to reproduce this issue in a fresh system, building everything from the master branch
Yes, I've been able to reproduce this issue in a fresh system, building everything from the
masterbranch
Thank you for following up and confirming it's reproducible without the docker setup.
I did notice that there are multiple crash related issues for the extension which may certainly be related.
I don't think these crash issues with the VScode extension are related. The reason why I filed this issue with Theia is because this particular error does not happen with VS code. It looks like this problem happens because some sets of Position parameters are incorrectly serialized.
My understanding is that the serialization of LSP requests is not directly performed by the extension, but rather gets delegated to a javascript library (languageclient), which is normally provided by VS code. Would it be possible that the version of this library, as shipped by Theia, is not the same as VS Code?
So the Julia extension defines an interface
export interface VersionedTextDocumentPositionParams {
textDocument: vslc.TextDocumentIdentifier,
version: number,
position: vscode.Position
}
which is then used via
const params: VersionedTextDocumentPositionParams = {
textDocument: vslc.TextDocumentIdentifier.create(document.uri.toString()),
version: document.version,
position: position # this is a vscode.Position
}
vslc_language_client.sendRequest<string>('julia/getModuleAt', params)
e.g. here.
Turns out that Theia serializes the vscocde.Position in that object as
{
"_line": 1,
"_character":2
}
instead of VSCode's
{
"line": 1,
"character": 2
}
which is what our server expects. You could argue that we should define the serialization ourselves, but that's not quite in the spirit of Theia trying to support VSCode extensions out-of-the-box.
Most helpful comment
So the Julia extension defines an interface
which is then used via
e.g. here.
Turns out that Theia serializes the
vscocde.Positionin that object asinstead of VSCode's
which is what our server expects. You could argue that we should define the serialization ourselves, but that's not quite in the spirit of Theia trying to support VSCode extensions out-of-the-box.