mathworks / mathworks/MATLAB-language-server

The language server is unable to start and connect to Matlab properly in VS Code

Open
#60 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
125
Forks
21
PR merge metrics
No merged PRs in 30d

Description

I also reported this at mathworks/MATLAB-extension-for-vscode#226, but I didn't get a response, and figured it may actually be more relevant here.

Describe the bug
Whenever I open a matlab file, the extension shows the following popup:

Image

And features which depend on a running matlab instance do not work. This is regardless of whether there is already currently a running instance of matlab. The output pane shows:

(11:39:30) matlabls: Log Directory: <...>
(11:39:30) matlabls: Launching MATLAB...
(11:39:36) matlabls: Started MATLAB (session 1)
(11:39:36) matlabls: MATLAB session 1 connected to R2024b
(11:39:36) matlabls: CWD set to: <...>
(11:39:36) matlabls: Adding workspace folder(s) to the MATLAB Path: 
	<...>
[Warn  - 11:39:36 AM] (11:39:36) matlabls - WARNING: Error while communicating with MATLAB - disconnecting
(11:39:36) matlabls: Shutting down MATLAB session 1
(11:39:36) matlabls: MATLAB process (session 1) terminated
Timeout when attaching to release: 24b
Retrying attach
Timeout when attaching to release: 24b
Retrying attach
Timeout when attaching to release: 24b
Unable to attach after retries

The matlab log is:

To get started, type doc.
For product information, visit www.mathworks.com.
matlabls: Beginning initialization
matlabls: matlabroot is 
C:\Program Files\MATLAB\R2024b
Printing connection data to file: <...>
matlabls: Initialization complete
For product information, visit www.mathworks.com.

There is no file named what is shown after "Printing connection data to file:". When I open task manager while pressing the "Connect to MATLAB" button, it shows an instance of the correct version of MATLAB appearing, and then disappearing shortly after (presumably because the language server has killed it when it prints "Shutting down MATLAB session 1"). Unfortunately it doesn't last long enough to follow the steps detailed in this comment. I'm wondering if maybe there is a flag that I can pass to Matlab manually that would let me check the steps listed in this comment?

Useful Information

  • OS Version: Windows 10
  • VS Code Version: 1.97.2 (not WSL)
  • Matlab Version: R2023b/R2024b (Not WSL; Tried both)

I have no startup scripts, and typing matlab into a shell starts it up properly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure on Windows 10 with VS Code 1.97.2 and MATLAB R2023b or R2024b, then inspect the language-server and MATLAB output around connection-data-file creation and the attach timeout. Done means the language server remains connected to MATLAB and dependent features work without the session terminating.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.