MATLAB-extension-for-vscode icon indicating copy to clipboard operation
MATLAB-extension-for-vscode copied to clipboard

MATLAB fails to launch when file descriptor limits are not set

Open goldenbergdaniel opened this issue 9 months ago • 5 comments

Describe the bug When I open a MATLAB project in VSCode, the extension gets stuck on the "establishing connection" stage. This means I am unable to run files from VSCode, nor use the autocomplete. I have tried with and without MATLAB open, both to the same result. The MATLAB install path is identical to what MATLAB gives me.

MATLAB LSP in the output window:

(16:06:58) matlabls: Log Directory: /tmp/matlabls_145980
(16:06:58) matlabls: Found cached licensing information...
(16:06:58) matlabls: Directory created or already exists: /home/dg/.matlab/MWI/hosts/ubuntu
(16:06:58) matlabls: Successfully marshaled environment variables for MATLAB
(16:06:58) matlabls: Launching MATLAB...
(16:06:59) matlabls: Successfully fetched entitlements
Using cached Online Licensing to launch MATLAB.
(16:06:59) matlabls: File written successfully to /home/dg/.matlab/MWI/hosts/ubuntu/proxy_app_config.json

Useful Information

  • OS Version: Ubuntu 24.10
  • VS Code Version: 1.95.2

Additional context I am using MATLAB on the student license, and its installed to my home directory (/home/dg/tools/matlab).

goldenbergdaniel avatar Feb 04 '25 21:02 goldenbergdaniel

After some time of waiting, I get this in the output:

(16:16:45) matlabls: MATLAB process (session 1) terminated
(16:16:45) matlabls: Shutting down MATLAB session 1 [Error - 4:16:45 PM] 
(16:16:45) matlabls - ERROR: MATLAB onStart connection failed: Error: MATLAB process terminated unexpectedly

goldenbergdaniel avatar Feb 04 '25 21:02 goldenbergdaniel

Update: The problem is that when the language server attempts to launch MATLAB, it doesn't set the correct number of file descriptors (which is something I have to do in the terminal from which I launch MATLAB). So if I run VSCode from a terminal with those file descriptor limits set, the extension works as expected. I'll leave this issue up but I think this is more relevant to the LSP.

goldenbergdaniel avatar Feb 05 '25 14:02 goldenbergdaniel

Hi @GoldenbergDaniel , thanks for the update on this!

Can you share more info about how you are setting the file descriptor limits?

dklilley avatar Feb 05 '25 14:02 dklilley

ulimit -n 4096
ulimit -u 23741

These have to be set from the shell in order to launch MATLAB from that shell. I got them from this page: https://www.mathworks.com/help/parallel-computing/recommended-system-limits-for-macintosh-and-linux.html

goldenbergdaniel avatar Feb 05 '25 14:02 goldenbergdaniel

It appears that the documentation page describes how to make these changes on a system-level, to avoid needing to specify these values every time MATLAB is launched.

Is this something which would work for you?

dklilley avatar Feb 06 '25 21:02 dklilley

We have not seen this issue reported by anyone else. Closing with the above workaround.

If this is still an active issue, please add a comment and this issue can be reopened for investigation.

dklilley avatar Jul 02 '25 18:07 dklilley