mathworks / MATLAB-language-server

MIT License
86 stars 9 forks source link

MATLAB refuses to connect #10

Closed krzysid closed 1 year ago

krzysid commented 1 year ago

The server seems to fail to refuse to connect to matlab on my machine. A few seconds after starting it just spits out WARNING: Error while communicating with MATLAB - disconnecting. I'm not sure what the issue is. MATLAB runs, as I can see it in htop (and is still running after the above message), and there there are normal-looking logs in the /tmp/matlabls_* directories, as well as the matlabls_conn.js file. Example MATLAB log:

< M A T L A B (R) >
                  Copyright 1984-2023 The MathWorks, Inc.
             R2023a Update 2 (9.14.0.2254940) 64-bit (glnxa64)
                               April 17, 2023

Warning: X does not support locale pl_PL.UTF-8

To get started, type doc.
For product information, visit www.mathworks.com.

matlabls: Beginning initialization
matlabls: matlabroot is 
/home/krzysiek/apps/matlab/R2023a
c = 

  struct with fields:

        matlabPid: 6821
    matlabRelease: 'R2023a'
Printing connection data to file:     /tmp/matlabls_6805/matlabls_conn.json
matlabls: Initialization complete

I'm using Void Linux. I'm using Neovim with Mason and nvim-lspconfig, but after a short test it doesn't seem to work in vscode either.

Relevant snippet of configuration:

lspconfig.matlab_ls.setup {
    filetypes = { 'matlab' },
    settings = {
        matlab = {
            ShouldIndexWorkspace = true,
            installPath = "/home/krzysiek/apps/matlab/R2023a/",
        }
    },
    single_file_support = true,
    capabilities = capabilities,
}

What might the issue be? MATLAB takes a while (around ~20 seconds) to start on my machine, so perhaps a timeout?

hamidingit commented 1 year ago

Thanks for the detailed information. The void linux is currently unsupported for MATLAB (and VS Code) but we can try few things to narrow this down.

my guess is that there is some level of security on your system that is preventing our connection from LSP to MATLAB on your box. to narrow it down more, try these steps:

sudo lsof -i -P -n > lsof.txt

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ...ENTRIES... MATLAB 1871305 userA 1120u IPv4 405765103 0t0 TCP 127.0.0.1:35737 (LISTEN)

curl -v -k https://127.0.0.1:35737

krzysid commented 1 year ago

Hello, this is the curl output:

*   Trying 127.0.0.1:40721...
* Connected to 127.0.0.1 (127.0.0.1) port 40721 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: C=US; O=company; CN=127.0.0.1; OU=engineering
*  start date: Aug 18 12:56:23 2023 GMT
*  expire date: Aug 17 12:56:23 2024 GMT
*  issuer: C=US; O=company; CN=127.0.0.1; OU=engineering
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 127.0.0.1:40721
> User-Agent: curl/8.1.2
> Accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/1.1 200 OK
< Date: Fri, 18 Aug 2023 12:58:28 GMT
< Connection: Keep-Alive
< Last-Modified: Thu, 31 Mar 2016 17:30:20 GMT
< ETag: "1459445420211"
< Content-Length: 211
< X-Content-Security-Policy: default-src 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; style-src 'self' 'unsafe-inline' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; img-src 'self' blob *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:* data:; font-src 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:* data:; frame-ancestors 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; frame-src 'self' https://www.getfeedback.com *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; connect-src 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:* wss://localhost:* wss://127.0.0.1:*
< Cache-Control: no-cache, no-store, must-revalidate
< Accept-Ranges: bytes
< X-Frame-Options: sameorigin
< Referrer-Policy: strict-origin
< Content-Security-Policy: default-src 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; style-src 'self' 'unsafe-inline' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; img-src 'self' blob *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:* data:; font-src 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:* data:; frame-ancestors 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; frame-src 'self' https://www.getfeedback.com *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:*; connect-src 'self' *.mathworks.com:* *.thingspeak.com:* thingspeak.com:* *.matlab.com:* https://localhost:* https://127.0.0.1:* wss://localhost:* wss://127.0.0.1:*
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Content-Type: text/html
< X-Content-Type-Options: nosniff
< Pragma: no-cache
< X-XSS-Protection: 1; mode=block
< Expires: Wed, 21 Oct 2015 07:28:00 GMT
< Set-Cookie: JSESSIONID2=DbMwIS0mRwRjkmS3; Path=/; HttpOnly; Secure; SameSite=None
< 
<!doctype html>
<html>
<head>
    <title>connector service</title>
    <link href="/css/connector.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <h1>The connector service is running.</h1>
</body>
</html>
* Connection #0 to host 127.0.0.1 left intact
tiagovla commented 1 year ago

I got the same issue using arch. For me, it does work on vscode. Same curl response as @krzysid. I will try to bisect the server's commits, I had it working a few months ago.

I thought it was breaking the connection because the response's name of the workspace/workspaceFolders method had slashes unlike the vscode's response. But it was not the case, I tested it with the exact response.

Another thing to consider is whether the client needs to wait the matlab/connection/update/server with connected status before doing anything.

Logs from neovim ```[START][2023-09-04 18:05:05] LSP logging initiated [INFO][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:634 "Starting RPC client" { args = { "/home/tiagovla/.vscode/extensions/mathworks.language-matlab-1.1.2/server/out/entry.js", "--stdio" }, cmd = "/home/tiagovla/.local/share/rtx/installs/node/19.5.0/bin/node", extra = { cwd = "/home/tiagovla/tmp/matlab_test" }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 1, jsonrpc = "2.0", method = "initialize", params = { capabilities = { general = { positionEncodings = { "utf-16" } }, textDocument = { callHierarchy = { dynamicRegistration = false }, codeAction = { codeActionLiteralSupport = { codeActionKind = { valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" } } }, dataSupport = true, dynamicRegistration = true, isPreferredSupport = true, resolveSupport = { properties = { "edit" } } }, completion = { completionItem = { commitCharactersSupport = false, deprecatedSupport = false, documentationFormat = { "markdown", "plaintext" }, preselectSupport = false, snippetSupport = false }, completionItemKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 } }, contextSupport = false, dynamicRegistration = false }, declaration = { linkSupport = true }, definition = { dynamicRegistration = true, linkSupport = true }, diagnostic = { dynamicRegistration = false }, documentHighlight = { dynamicRegistration = false }, documentSymbol = { dynamicRegistration = false, hierarchicalDocumentSymbolSupport = true, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, formatting = { dynamicRegistration = true }, hover = { contentFormat = { "markdown", "plaintext" }, dynamicRegistration = true }, implementation = { linkSupport = true }, inlayHint = { dynamicRegistration = true, resolveSupport = { properties = {} } }, publishDiagnostics = { dataSupport = true, relatedInformation = true, tagSupport = { valueSet = { 1, 2 } } }, rangeFormatting = { dynamicRegistration = true }, references = { dynamicRegistration = false }, rename = { dynamicRegistration = true, prepareSupport = true }, semanticTokens = { augmentsSyntaxTokens = true, dynamicRegistration = false, formats = { "relative" }, multilineTokenSupport = false, overlappingTokenSupport = true, requests = { full = { delta = true }, range = false }, serverCancelSupport = false, tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" }, tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" } }, signatureHelp = { dynamicRegistration = false, signatureInformation = { activeParameterSupport = true, documentationFormat = { "markdown", "plaintext" }, parameterInformation = { labelOffsetSupport = true } } }, synchronization = { didSave = true, dynamicRegistration = false, willSave = true, willSaveWaitUntil = true }, typeDefinition = { linkSupport = true } }, window = { showDocument = { support = true }, showMessage = { messageActionItem = { additionalPropertiesSupport = false } }, workDoneProgress = true }, workspace = { applyEdit = true, configuration = true, didChangeWatchedFiles = { dynamicRegistration = true, relativePatternSupport = true }, inlayHint = { refreshSupport = true }, semanticTokens = { refreshSupport = true }, symbol = { dynamicRegistration = false, symbolKind = { valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 } } }, workspaceEdit = { resourceOperations = { "rename", "create", "delete" } }, workspaceFolders = true } }, clientInfo = { name = "Neovim", version = "0.10.0-dev+b641fc387" }, initializationOptions = vim.empty_dict(), processId = 257548, rootPath = "/home/tiagovla/tmp/matlab_test", rootUri = "file:///home/tiagovla/tmp/matlab_test", trace = "off", workspaceFolders = { { name = "/home/tiagovla/tmp/matlab_test", uri = "file:///home/tiagovla/tmp/matlab_test" } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "(18:05:05) matlabls: Log Directory: /tmp/matlabls_257560", type = 4 }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 1, jsonrpc = "2.0", result = { capabilities = { codeActionProvider = true, completionProvider = { triggerCharacters = { ".", "(", " ", ",", "/", "\\" } }, definitionProvider = true, documentFormattingProvider = true, documentSymbolProvider = true, executeCommandProvider = { commands = { "matlabls.lint.suppress.line", "matlabls.lint.suppress.file" } }, referencesProvider = true, signatureHelpProvider = { triggerCharacters = { "(", "," } }, textDocumentSync = 2 } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "initialized", params = vim.empty_dict()} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "workspace/didChangeConfiguration", params = { settings = { matlab = { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "workspace/didChangeConfiguration", params = { settings = { matlab = { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } } }} [INFO][2023-09-04 18:05:05] .../lua/vim/lsp.lua:1444 "LSP[matlab_ls]" "server_capabilities" { server_capabilities = { codeActionProvider = true, completionProvider = { triggerCharacters = { ".", "(", " ", ",", "/", "\\" } }, definitionProvider = true, documentFormattingProvider = true, documentSymbolProvider = true, executeCommandProvider = { commands = { "matlabls.lint.suppress.line", "matlabls.lint.suppress.file" } }, referencesProvider = true, signatureHelpProvider = { triggerCharacters = { "(", "," } }, textDocumentSync = { change = 2, openClose = true, save = { includeText = false }, willSave = false, willSaveWaitUntil = false } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didOpen", params = { textDocument = { languageId = "matlab", text = "y = linspace(1,2,10);\nx = linspace(1,4,10);\nplot(x,y)\n\nPlot\n", uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 0 } }} [DEBUG][2023-09-04 18:05:05] .../lua/vim/lsp.lua:1492 "LSP[matlab_ls]" "client.request" 1 "textDocument/documentSymbol" { textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" }} 1 [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 2, jsonrpc = "2.0", method = "textDocument/documentSymbol", params = { textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 0, jsonrpc = "2.0", method = "client/registerCapability", params = { registrations = { { id = "d43d58eb-672f-41a0-bd4a-6b69d2cd2f31", method = "workspace/didChangeConfiguration", registerOptions = vim.empty_dict() } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 1, jsonrpc = "2.0", method = "client/registerCapability", params = { registrations = { { id = "86783d01-ffa0-4672-97ee-118e69f9c4d2", method = "workspace/didChangeWorkspaceFolders", registerOptions = vim.empty_dict() } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 2, jsonrpc = "2.0", method = "workspace/configuration", params = { items = { { section = "MATLAB" } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 3, jsonrpc = "2.0", method = "workspace/configuration", params = { items = { { section = "MATLAB" } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 4, jsonrpc = "2.0", method = "workspace/configuration", params = { items = { { section = "MATLAB" } } }} [WARN][2023-09-04 18:05:05] ...lsp/handlers.lua:134 "The language server matlab_ls triggers a registerCapability handler for workspace/didChangeConfiguration despite dynamicRegistration set to false. Report upstream, this warning is harmless" [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = vim.NIL, status = true} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 0, jsonrpc = "2.0", result = vim.NIL} [WARN][2023-09-04 18:05:05] ...lsp/handlers.lua:134 "The language server matlab_ls triggers a registerCapability handler for workspace/didChangeWorkspaceFolders despite dynamicRegistration set to false. Report upstream, this warning is harmless" [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = vim.NIL, status = true} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 1, jsonrpc = "2.0", result = vim.NIL} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "telemetry/logdata", params = { data = { action_type = "openFile", result = "1" }, eventKey = "ACTIONS" }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 5, jsonrpc = "2.0", method = "workspace/configuration", params = { items = { { section = "MATLAB" } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }, status = true} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 2, jsonrpc = "2.0", result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 6, jsonrpc = "2.0", method = "workspace/configuration", params = { items = { { section = "MATLAB" } } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }, status = true} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 3, jsonrpc = "2.0", result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }, status = true} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 4, jsonrpc = "2.0", result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }, status = true} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 5, jsonrpc = "2.0", result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }, status = true} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 6, jsonrpc = "2.0", result = { { indexWorkspace = true, installPath = "/usr/local/MATLAB/R2023a", matlabConnectionTiming = "onStart", telemetry = true } }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "matlab/connection/update/server", params = { connectionStatus = "connecting" }} [DEBUG][2023-09-04 18:05:05] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "(18:05:05) matlabls: Launching MATLAB...", type = 4 }} [DEBUG][2023-09-04 18:05:06] .../lua/vim/lsp.lua:1492 "LSP[matlab_ls]" "client.request" 1 "textDocument/documentSymbol" { textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" }} 1 [DEBUG][2023-09-04 18:05:06] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 3, jsonrpc = "2.0", method = "textDocument/documentSymbol", params = { textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" } }} [DEBUG][2023-09-04 18:05:06] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "textDocument/publishDiagnostics", params = { diagnostics = {}, uri = "file:///home/tiagovla/tmp/matlab_test/test.m" }} [DEBUG][2023-09-04 18:05:08] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 4, line = 4 }, start = { character = 3, line = 4 } }, rangeLength = 1, text = "" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 4 } }} [DEBUG][2023-09-04 18:05:08] .../lua/vim/lsp.lua:1492 "LSP[matlab_ls]" "client.request" 1 "textDocument/completion" { context = { triggerKind = 1 }, position = { character = 3, line = 4 }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" }} 1 [DEBUG][2023-09-04 18:05:08] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 4, jsonrpc = "2.0", method = "textDocument/completion", params = { context = { triggerKind = 1 }, position = { character = 3, line = 4 }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" } }} [DEBUG][2023-09-04 18:05:08] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 4, jsonrpc = "2.0", result = { isIncomplete = false, items = {} }} [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 3, line = 4 }, start = { character = 2, line = 4 } }, rangeLength = 1, text = "" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 5 } }} [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 2, line = 4 }, start = { character = 1, line = 4 } }, rangeLength = 1, text = "" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 6 } }} [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 1, line = 4 }, start = { character = 0, line = 4 } }, rangeLength = 1, text = "" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 7 } }} [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 0, line = 4 }, start = { character = 0, line = 4 } }, rangeLength = 0, text = "p" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 8 } }} [DEBUG][2023-09-04 18:05:09] .../lua/vim/lsp.lua:1492 "LSP[matlab_ls]" "client.request" 1 "textDocument/completion" { context = { triggerKind = 1 }, position = { character = 1, line = 4 }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" }} 1 [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 5, jsonrpc = "2.0", method = "textDocument/completion", params = { context = { triggerKind = 1 }, position = { character = 1, line = 4 }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m" } }} [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 5, jsonrpc = "2.0", result = { isIncomplete = false, items = {} }} [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 1, line = 4 }, start = { character = 1, line = 4 } }, rangeLength = 0, text = "l" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 9 } }} [DEBUG][2023-09-04 18:05:09] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 2, line = 4 }, start = { character = 2, line = 4 } }, rangeLength = 0, text = "o" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 10 } }} [DEBUG][2023-09-04 18:05:10] .../vim/lsp/rpc.lua:261 "rpc.send" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { range = { ["end"] = { character = 3, line = 4 }, start = { character = 3, line = 4 } }, rangeLength = 0, text = "t" } }, textDocument = { uri = "file:///home/tiagovla/tmp/matlab_test/test.m", version = 11 } }} [DEBUG][2023-09-04 18:05:15] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "(18:05:15) matlabls: Started MATLAB", type = 4 }} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "matlab/connection/update/server", params = { connectionStatus = "connected" }} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "telemetry/logdata", params = { data = { action_type = "startMATLAB", result = "R2023a" }, eventKey = "ACTIONS" }} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:364 "rpc.receive" { id = 7, jsonrpc = "2.0", method = "workspace/workspaceFolders"} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:380 "server_request: callback result" { result = { { name = "/home/tiagovla/tmp/matlab_test", uri = "file:///home/tiagovla/tmp/matlab_test" } }, status = true} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:261 "rpc.send" { id = 7, jsonrpc = "2.0", result = { { name = "/home/tiagovla/tmp/matlab_test", uri = "file:///home/tiagovla/tmp/matlab_test" } }} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "window/logMessage", params = { message = "(18:05:16) matlabls - WARNING: Error while communicating with MATLAB - disconnecting", type = 2 }} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "matlab/connection/update/server", params = { connectionStatus = "disconnected" }} [DEBUG][2023-09-04 18:05:16] .../vim/lsp/rpc.lua:364 "rpc.receive" { jsonrpc = "2.0", method = "telemetry/logdata", params = { data = { action_type = "shutdownMATLAB", result = "Error while communicating with MATLAB" }, eventKey = "ACTIONS" }} ```
Logs from vscode [Working] ``` ARGS: /home/tiagovla/.vscode/extensions/mathworks.language-matlab-1.1.2/server/out/index.js,--matlabInstallPath=/usr/local/MATLAB/R2023a,--matlabConnectionTiming=onStart,--indexWorkspace,--node-ipc,--clientProcessId=253908 INPUT { "jsonrpc": "2.0", "id": 0, "method": "initialize", "params": { "processId": 253908, "clientInfo": { "name": "Visual Studio Code", "version": "1.81.1" }, "locale": "en", "rootPath": "/home/tiagovla/tmp/matlab_test", "rootUri": "file:///home/tiagovla/tmp/matlab_test", "capabilities": { "workspace": { "applyEdit": true, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "rename", "delete" ], "failureHandling": "textOnlyTransactional", "normalizesLineEndings": true, "changeAnnotationSupport": { "groupsOnLabel": true } }, "configuration": true, "didChangeWatchedFiles": { "dynamicRegistration": true, "relativePatternSupport": true }, "symbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "tagSupport": { "valueSet": [ 1 ] }, "resolveSupport": { "properties": [ "location.range" ] } }, "codeLens": { "refreshSupport": true }, "executeCommand": { "dynamicRegistration": true }, "didChangeConfiguration": { "dynamicRegistration": true }, "workspaceFolders": true, "semanticTokens": { "refreshSupport": true }, "fileOperations": { "dynamicRegistration": true, "didCreate": true, "didRename": true, "didDelete": true, "willCreate": true, "willRename": true, "willDelete": true }, "inlineValue": { "refreshSupport": true }, "inlayHint": { "refreshSupport": true }, "diagnostics": { "refreshSupport": true } }, "textDocument": { "publishDiagnostics": { "relatedInformation": true, "versionSupport": false, "tagSupport": { "valueSet": [ 1, 2 ] }, "codeDescriptionSupport": true, "dataSupport": true }, "synchronization": { "dynamicRegistration": true, "willSave": true, "willSaveWaitUntil": true, "didSave": true }, "completion": { "dynamicRegistration": true, "contextSupport": true, "completionItem": { "snippetSupport": true, "commitCharactersSupport": true, "documentationFormat": [ "markdown", "plaintext" ], "deprecatedSupport": true, "preselectSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "insertReplaceSupport": true, "resolveSupport": { "properties": [ "documentation", "detail", "additionalTextEdits" ] }, "insertTextModeSupport": { "valueSet": [ 1, 2 ] }, "labelDetailsSupport": true }, "insertTextMode": 2, "completionItemKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ] }, "completionList": { "itemDefaults": [ "commitCharacters", "editRange", "insertTextFormat", "insertTextMode" ] } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "markdown", "plaintext" ] }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "markdown", "plaintext" ], "parameterInformation": { "labelOffsetSupport": true }, "activeParameterSupport": true }, "contextSupport": true }, "definition": { "dynamicRegistration": true, "linkSupport": true }, "references": { "dynamicRegistration": true }, "documentHighlight": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "labelSupport": true }, "codeAction": { "dynamicRegistration": true, "isPreferredSupport": true, "disabledSupport": true, "dataSupport": true, "resolveSupport": { "properties": [ "edit" ] }, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] } }, "honorsChangeAnnotations": false }, "codeLens": { "dynamicRegistration": true }, "formatting": { "dynamicRegistration": true }, "rangeFormatting": { "dynamicRegistration": true }, "onTypeFormatting": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true, "prepareSupportDefaultBehavior": 1, "honorsChangeAnnotations": true }, "documentLink": { "dynamicRegistration": true, "tooltipSupport": true }, "typeDefinition": { "dynamicRegistration": true, "linkSupport": true }, "implementation": { "dynamicRegistration": true, "linkSupport": true }, "colorProvider": { "dynamicRegistration": true }, "foldingRange": { "dynamicRegistration": true, "rangeLimit": 5000, "lineFoldingOnly": true, "foldingRangeKind": { "valueSet": [ "comment", "imports", "region" ] }, "foldingRange": { "collapsedText": false } }, "declaration": { "dynamicRegistration": true, "linkSupport": true }, "selectionRange": { "dynamicRegistration": true }, "callHierarchy": { "dynamicRegistration": true }, "semanticTokens": { "dynamicRegistration": true, "tokenTypes": [ "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" ], "tokenModifiers": [ "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" ], "formats": [ "relative" ], "requests": { "range": true, "full": { "delta": true } }, "multilineTokenSupport": false, "overlappingTokenSupport": false, "serverCancelSupport": true, "augmentsSyntaxTokens": true }, "linkedEditingRange": { "dynamicRegistration": true }, "typeHierarchy": { "dynamicRegistration": true }, "inlineValue": { "dynamicRegistration": true }, "inlayHint": { "dynamicRegistration": true, "resolveSupport": { "properties": [ "tooltip", "textEdits", "label.tooltip", "label.location", "label.command" ] } }, "diagnostic": { "dynamicRegistration": true, "relatedDocumentSupport": false } }, "window": { "showMessage": { "messageActionItem": { "additionalPropertiesSupport": true } }, "showDocument": { "support": true }, "workDoneProgress": true }, "general": { "staleRequestSupport": { "cancel": true, "retryOnContentModified": [ "textDocument/semanticTokens/full", "textDocument/semanticTokens/range", "textDocument/semanticTokens/full/delta" ] }, "regularExpressions": { "engine": "ECMAScript", "version": "ES2020" }, "markdown": { "parser": "marked", "version": "1.1.0" }, "positionEncodings": [ "utf-16" ] }, "notebookDocument": { "synchronization": { "dynamicRegistration": true, "executionSummarySupport": true } } }, "trace": "off", "workspaceFolders": [ { "uri": "file:///home/tiagovla/tmp/matlab_test", "name": "matlab_test" } ] } } OUTPUT { "jsonrpc": "2.0", "method": "window/logMessage", "params": { "type": 4, "message": "(17:59:51) matlabls: Log Directory: /tmp/matlabls_253965" } } OUTPUT { "jsonrpc": "2.0", "id": 0, "result": { "capabilities": { "codeActionProvider": true, "completionProvider": { "triggerCharacters": [ ".", "(", " ", ",", "/", "\\" ] }, "definitionProvider": true, "documentFormattingProvider": true, "executeCommandProvider": { "commands": [ "matlabls.lint.suppress.line", "matlabls.lint.suppress.file" ] }, "referencesProvider": true, "signatureHelpProvider": { "triggerCharacters": [ "(", "," ] }, "documentSymbolProvider": true, "textDocumentSync": 2 } } } INPUT { "jsonrpc": "2.0", "method": "initialized", "params": {} } OUTPUT { "jsonrpc": "2.0", "id": 0, "method": "client/registerCapability", "params": { "registrations": [ { "id": "f7622083-7b0b-4562-8e69-5566e46c8c44", "method": "workspace/didChangeConfiguration", "registerOptions": {} } ] } } OUTPUT { "jsonrpc": "2.0", "id": 1, "method": "client/registerCapability", "params": { "registrations": [ { "id": "615260f6-17b2-460b-bd19-76fc2a896745", "method": "workspace/didChangeWorkspaceFolders", "registerOptions": {} } ] } } OUTPUT { "jsonrpc": "2.0", "id": 2, "method": "workspace/configuration", "params": { "items": [ { "section": "MATLAB" } ] } } INPUT { "jsonrpc": "2.0", "method": "textDocument/didOpen", "params": { "textDocument": { "uri": "file:///home/tiagovla/tmp/matlab_test/test.m", "languageId": "matlab", "version": 1, "text": "y = linspace(1,2,10);\nx = linspace(1,4,10);\nplot(x,y)\n\nplot\n" } } } OUTPUT { "jsonrpc": "2.0", "method": "telemetry/logdata", "params": { "eventKey": "ACTIONS", "data": { "action_type": "openFile", "result": "1" } } } OUTPUT { "jsonrpc": "2.0", "id": 3, "method": "workspace/configuration", "params": { "items": [ { "section": "MATLAB" } ] } } INPUT { "jsonrpc": "2.0", "id": 0, "result": null } INPUT { "jsonrpc": "2.0", "id": 1, "method": "textDocument/codeAction", "params": { "textDocument": { "uri": "file:///home/tiagovla/tmp/matlab_test/test.m" }, "range": { "start": { "line": 4, "character": 4 }, "end": { "line": 4, "character": 4 } }, "context": { "diagnostics": [], "triggerKind": 2 } } } INPUT { "jsonrpc": "2.0", "id": 1, "result": null } OUTPUT { "jsonrpc": "2.0", "id": 1, "result": [] } INPUT { "jsonrpc": "2.0", "id": 2, "result": [ { "installPath": "/usr/local/MATLAB/R2023a", "matlabConnectionTiming": "onStart", "indexWorkspace": true, "telemetry": true } ] } OUTPUT { "jsonrpc": "2.0", "method": "matlab/connection/update/server", "params": { "connectionStatus": "connecting" } } OUTPUT { "jsonrpc": "2.0", "method": "window/logMessage", "params": { "type": 4, "message": "(17:59:51) matlabls: Launching MATLAB..." } } INPUT { "jsonrpc": "2.0", "id": 3, "result": [ { "installPath": "/usr/local/MATLAB/R2023a", "matlabConnectionTiming": "onStart", "indexWorkspace": true, "telemetry": true } ] } OUTPUT { "jsonrpc": "2.0", "method": "textDocument/publishDiagnostics", "params": { "uri": "file:///home/tiagovla/tmp/matlab_test/test.m", "diagnostics": [] } } INPUT { "jsonrpc": "2.0", "id": 2, "method": "textDocument/codeAction", "params": { "textDocument": { "uri": "file:///home/tiagovla/tmp/matlab_test/test.m" }, "range": { "start": { "line": 4, "character": 4 }, "end": { "line": 4, "character": 4 } }, "context": { "diagnostics": [], "triggerKind": 2 } } } OUTPUT { "jsonrpc": "2.0", "id": 2, "result": [] } INPUT { "jsonrpc": "2.0", "id": 3, "method": "textDocument/documentSymbol", "params": { "textDocument": { "uri": "file:///home/tiagovla/tmp/matlab_test/test.m" } } } OUTPUT { "jsonrpc": "2.0", "method": "window/logMessage", "params": { "type": 4, "message": "(18:00:01) matlabls: Started MATLAB" } } OUTPUT { "jsonrpc": "2.0", "method": "matlab/connection/update/server", "params": { "connectionStatus": "connected" } } OUTPUT { "jsonrpc": "2.0", "method": "telemetry/logdata", "params": { "eventKey": "ACTIONS", "data": { "action_type": "startMATLAB", "result": "R2023a" } } } OUTPUT { "jsonrpc": "2.0", "id": 4, "method": "workspace/workspaceFolders" } INPUT { "jsonrpc": "2.0", "id": 4, "result": [ { "uri": "file:///home/tiagovla/tmp/matlab_test", "name": "matlab_test" } ] } OUTPUT { "jsonrpc": "2.0", "method": "textDocument/publishDiagnostics", "params": { "uri": "file:///home/tiagovla/tmp/matlab_test/test.m", "diagnostics": [ { "range": { "start": { "line": 4, "character": 0 }, "end": { "line": 4, "character": 4 } }, "message": "Function might be called with too few arguments.", "severity": 2, "code": "LTARG", "source": "MATLAB" } ] } } ```
tiagovla commented 1 year ago

Alright, I found the problem! This LSP server doesn't work on newer versions of node (I was running 19.5.0). It does work on the version shipped with electron: 16.17.1. That's why vscode worked and nvim did not.

tiagovla commented 1 year ago

@hamidingit Probably something inside MatlabCommunicationManager.js.

hamidingit commented 1 year ago

Thanks @tiagovla for the investigation and narrowing it down!

it appears that the MATLAB language server component is impacted by newer version of Node ( most likely starting from v18.x ). The impact to user base is like this:

we are currently investigating this issue and will update this thread. For the meantime, if you are using VS Code, try to stay on v1.7x or lower versions until this is addressed. if you are using other IDEs like Neovim, try to use node version 16.x

dklilley commented 1 year ago

This issue should be resolved now (e6e87cc) in v1.1.5 of the language server, and has been released in v1.1.3 of the VS Code extension.

Please let me know if you still experience this issue after updating. For now, I am closing this issue.

scivision commented 10 months ago

I get similar symptoms on Apple Silicon macOS with Matlab R2023b and Matlab vscode version 1.1.6.

(Same error message in vscode Matlab extension, similar curl HTML output).

matlabls server is visible from curl and web browser like users posted above.

Version: 1.86.0
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:29:15.765Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0
scivision commented 10 months ago

On WIndows with Matlab R2023b, VScode 1.86.0 and Matlab extension v1.1.6:

Matlab grey window opens when I open .m script in VScode with animated Matlab L-shell logo repeating endlessly. I can open another Matlab desktop or invoke Matlab from the command line normally matlab -batch or similar.

dklilley commented 10 months ago

@scivision - it sounds like you might be using the New Desktop for MATLAB Beta. If so, there is currently a limitation which prevents the MATLAB Language Server from working with the New Desktop. This is currently being worked on, and is tracked here: mathworks/MATLAB-extension-for-vscode#24

scivision commented 9 months ago

@dklilley thanks switching to old desktop did indeed fix the problem.