coc-julia
coc-julia copied to clipboard
Julia language server failing to initialize
I apologize if I make any mistakes here, this is the first time I've reported something like this. Each time I open a julia file in nvim, the julia language server fails to initialize. This error is provided:
[coc.nvim] The "julia" server crashed 4 times in the last 3 minutes. The server wil l not be restarted.
I am running nodejs v16.14.0 and julia 1.7.3 on fedora 36. It may be worth noting that other language servers run without issue. Looking into the coc logs shows the following:
2022-08-08T13:06:21.649 INFO (pid:10173) [plugin] - coc.nvim initialized with node: v16.14.0 after 78ms 2022-08-08T13:06:24.895 INFO (pid:10173) [services] - registered service "julia" 2022-08-08T13:06:24.896 INFO (pid:10173) [services] - Julia Language Server state change: stopped => starting 2022-08-08T13:06:24.901 INFO (pid:10173) [language-client-index] - Language server "julia" started with 10232 2022-08-08T13:06:24.927 INFO (pid:10173) [services] - Julia Language Server state change: starting => stopped 2022-08-08T13:06:24.927 INFO (pid:10173) [services] - Julia Language Server state change: stopped => starting 2022-08-08T13:06:24.931 INFO (pid:10173) [language-client-index] - Language server "julia" started with 10234 2022-08-08T13:06:24.942 INFO (pid:10173) [services] - Julia Language Server state change: starting => stopped 2022-08-08T13:06:24.942 INFO (pid:10173) [services] - Julia Language Server state change: stopped => starting 2022-08-08T13:06:24.946 INFO (pid:10173) [language-client-index] - Language server "julia" started with 10236 2022-08-08T13:06:24.957 INFO (pid:10173) [services] - Julia Language Server state change: starting => stopped 2022-08-08T13:06:24.957 INFO (pid:10173) [services] - Julia Language Server state change: stopped => starting 2022-08-08T13:06:24.961 INFO (pid:10173) [language-client-index] - Language server "julia" started with 10238 2022-08-08T13:06:24.973 INFO (pid:10173) [services] - Julia Language Server state change: starting => stopped 2022-08-08T13:06:24.973 ERROR (pid:10173) [services] - Server julia failed to start: Error: Connection to server got closed. Server will not be restarted. at Zf.handleConnectionClosed (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:236:1006) at Zf.handleConnectionClosed (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:236:28588) at t (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:236:386) at xN.invoke (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:36:9670) at Md.fire (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:36:10436) at xi (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:37:10897) at xN.invoke (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:36:9670) at Md.fire (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:36:10436) at OS.fireClose (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:36:12716) at Socket.<anonymous> (/home/jangove/.local/share/nvim/plugged/coc.nvim/build/index.js:36:14275)
I have been trying to get coc-julia working with nvim for a while, but this problem has persisted between multiple operating system installs and multiple attempts to reinstall both coc and coc-julia. I'm sure I'm missing something simple here, but I'd really appreciate some help.
The Julia language server can't start on your env.
Thanks for your reply! Do you know which part of an env might prevent the server from starting?
There are many possible. I think you can check if the LanguageServer
is installed well firstly:
julia --project=~/.config/coc/extensions/node_modules/coc-julia/server/JuliaLS -e "using LanguageServer"
I ran into this same issue as well. When I ran the julia command above with the appropriate environment, the server immediately closed as soon as using LanguageServer
finished executing. I suspect this causes the lsp on nvim's side to fail.
I resolved the issue by using the manual configuration option provided by Coc:
{ "languageserver": { "julia": { "command": "/usr/local/bin/julia", "args" : ["--startup-file=no", "--history-file=no", "-e","using LanguageServer; runserver()"], "filetypes": ["julia"] } } }
A couple of points to note:
- Use the correct path to your Julia executable
- CoC executes Julia with the passed args. Note that -e imports the LanguageServer package and creates the server. If you notice that Julia immediately exits when running the command in isolation, check to see if you have
runserver()
.