Can not start Wolfram language server
dimakolo opened this issue · 9 comments
After following the instructions on the homepage of the repository I do get the code highlights and issues on the test example as well as the real project files, however, I still get the error message:
"Cannot start Wolfram language server. Check Output view and open the Wolfram Language Error Report output channel for more information. "
There is nothing helpful in the Wolfram Language output, but Wolfram Language Error Report shows the error that the Language server kernel did not start in 10 seconds. This is what I get from running the diagnostics in the notebook:
Needs["LSPServer`"];
LSPServer`RunServerDiagnostic[{"c:\Program Files\Wolfram Research\Mathematica\12.3\WolframKernel.exe","-noinit","-noprompt","-nopaclet","-nostartuppaclets","-noicon","-run","Needs[\"LSPServer`\"];LSPServer`StartServer[]"}]
Kernel that is running RunServerDiagnostic[] ($CommandLine[[1]]): WolframKernel
Kernel that RunServerDiagnostic[] will start (RunServerDiagnostic[{kernel, ...}]): c:\Program Files\Wolfram Research\Mathematica\12.3\WolframKernel.exe
WARNING: RunServerDiagnostic[] should be run with same kernel that RunServerDiagnostic[] will start.
Starting Language Server kernel with command: {c:\Program Files\Wolfram Research\Mathematica\12.3\WolframKernel.exe,-noinit,-noprompt,-nopaclet,-nostartuppaclets,-noicon,-run,Needs["LSPServer`"];LSPServer`StartServer[]}
If any messages are printed below, they must be fixed.
Writing initialize...
ReadByteArray::InputStream[C:\Users\user\AppData\Roaming\Mathematica\ApplicationData\ProcessLink\Streams\wl-stream-stdout-15idkdmg23gkj,4] is not open
ERROR: ReadByteArray returned unevaluated; exiting hard
Process timed out after 30 seconds.
INFO: Exit code: None
Environments
OS: Windows_NT x64 10.0.19042
VS code Version: 1.63.2
Wolfram Engine Version : 12.3.0 for Microsoft Windows (64-bit) (May 10, 2021)
Wolfram Language Version: 1.4.0
I have a theory about this...
The server kernel started fine, but took more than 10 seconds for whatever reason (VSCode may have been updating or indexing and slowing things down, whatever)
Then trying to do RunServerDiagnostic in a notebook hits the license limit on the machine. There are 3 kernel processes running: server kernel that started fine, host kernel in the notebook session, and the child server kernel from RunServerDiagnostic.
Then the diagnostic times out after 30 seconds.
I will be adding various pieces to help with this:
- better messaging to describe what is going on
- mentioning license limits and encouraging exiting from VSCode before running the diagnostic
- setting to disable the warning if it regularly is taking more than 10 seconds to start kernel
I don't think the license limit should be an issue in this case - I have not had issues with launching 3 kernels on my PC at the same time. I have tested VSCode with no MM opened and it still did not launch in time (still got the same error in the Wolfram Language Error log).
I also tried to restart VSCode several times and add wait some time between opening it and opening the first Mathematica file. I also tried to clear out MM configuration folder in order to eliminate the possibility of this being an issue with my init.m files but that also did not help.
If this ends up being an issue that my system just does not load/launch the server in time, is there a way to increase the time limit from 10 seconds to something larger?
Yeah, I'm also now wondering about license theory.
There may be multiple issues at play.
For whatever reason, it may take more than 10 seconds to start kernels on some systems. I try to run with various options like -noinit -nopaclet -nostartuppaclets
to help startup time, but it may still take time.
Note also that -noinit
means that your init.m is not run.
If this is the case, then I will add a setting to just disable this warning. I don't want to increase the time or anything, because this is really testing whether everything is properly setup. If everything is setup properly and kernel takes 12 seconds to start, then there is no need for this warning at all. The warning after 10 seconds is really for when packages are not properly installed and the kernel really is hanging.
There may be another issue with RunServerDiagnostic
not working on Windows and Linux, and I am currently looking into this.
env:
WolframScript 1.3.0 for Linux-x86-64
Wolfram Language 12.1.0 Engine for Linux x86 (64-bit)
OS: Arch Linux x86_64
Running Language Server diagnostic...
Kernel that is running RunServerDiagnostic[] ($CommandLine[[1]]): /usr/local/Wolfram/WolframEngine/12.1/SystemFiles/Kernel/Binaries/Linux-x86-64/WolframKernel
Kernel that RunServerDiagnostic[] will start (RunServerDiagnostic[{kernel, ...}]): /usr/local/bin/WolframKernel
WARNING: RunServerDiagnostic[] should be run with same kernel that RunServerDiagnostic[] will start.
Starting Language Server kernel with command: {/usr/local/bin/WolframKernel, -noinit, -noprompt, -nopaclet, -noicon, -nostartuppaclets, -run, Needs["LSPServer`"];LSPServer`StartServer[]}
Loading from Wolfram Research server ...
If any messages are printed below, they must be fixed.
Writing initialize...
BinaryWrite::openx: OutputStream[in:0, 4] is not open.
BinaryWrite::openx: OutputStream[in:0, 4] is not open.
ERROR: BinaryWrite failed; exiting hard
Process timed out after 30 seconds.
INFO: Exit code: None
I have pushed changes to LSPServer that address this issue:
https://github.com/WolframResearch/LSPServer
Not officially released yet. Please build locally and let me know how it goes.
I have added a lot more functionality to RunServerDiagnostic.
I have also narrowed down a race condition that (sometimes) happens only on Linux (apparently).
I have worked around that issue. I have tested on Mac, Linux, and Windows and everything seems to be working.
I will not close just yet.
This time it got further into loading, but still errored out during the server diagnostics:
Running Language Server diagnostic...
IMPORTANT: Make sure that all other kernels are shut down before running this diagnostic.
Transient license limit errors may give false negatives.
INFORMATION: Host Kernel: WolframKernel
INFORMATION: Host Kernel version: 12.3
INFORMATION: Host Kernel Directory[]: C:\Users\user\Documents
INFORMATION: Host Kernel $MaxLicenseProcesses: 75
INFORMATION: Host Kernel LSPServer version: 1.5
INFORMATION: Host Kernel CodeParser version: 1.4
INFORMATION: Host Kernel CodeInspector version: 1.4
INFORMATION: Host Kernel CodeFormatter version: 1.4
INFORMATION: Host Kernel LSPServer build date: Tue 18 Jan 2022 09:10:57
INFORMATION: Host Kernel CodeParser build date: Sun 21 Nov 2021 22:59:41
INFORMATION: Host Kernel CodeInspector build date: Sun 21 Nov 2021 18:08:13
INFORMATION: Host Kernel CodeFormatter build date: Sun 21 Nov 2021 23:13:18
Start Stage 1
Checking whether bug 410895 is present and work-around is needed...
Starting Mini Server kernel with command: {c:\Program Files\Wolfram Research\Mathematica\12.3\WolframKernel.exe,-noinit,-noprompt,-nopaclet,-noicon,-nostartuppaclets,-run,Test410895[(*"*)];ToExpression[FromCharacterCode[{78, 101, 101, 100, 115, 91, 34, 76, 83, 80, 83, 101, 114, 118, 101, 114, 96, 34, 93, 59, 76, 83, 80, 83, 101, 114, 118, 101, 114, 96, 83, 101, 114, 118, 101, 114, 68, 105, 97, 103, 110, 111, 115, 116, 105, 99, 115, 96, 83, 116, 97, 114, 116, 77, 105, 110, 105, 83, 101, 114, 118, 101, 114, 91, 93}]]}
Waiting maximum of 30 seconds for any hangs.
Sanity checking...
ERROR: Unexpected EndOfFile; exiting hard
Process already finished.
INFO: Exit code: 0
I could not reproduce the exact output that you posted, but I did address other issues that may have been the cause. If you can, please checkout the latest changes in LSPServer and try again. I am interested if there are any other loose ends.
Also, I want to verify that this is only the diagnostics that you are seeing trouble with. The actual server runs correctly?
I used a paclet that I compiled in a linux VM on Windows which might have been a mistake. When I use it in linux everything is totally fine (launches without errors and works fine) as opposed to LSPServer-1.4 that did not want to start.
I'm going to close this issue, but let me know if anything else goes wrong.