oraios/serena · error · RuntimeError

MATLAB Language Server script not found at: {server_script}

Error message

MATLAB Language Server script not found at: {server_script}

What it means

As a final sanity check before building the `[node, server_script, --stdio]` command, create_launch_command verifies the script returned by _get_executable_path actually exists on disk. If not, RuntimeError is raised — usually a race or path inconsistency between extension resolution and script lookup.

Source

Thrown at src/solidlsp/language_servers/matlab_language_server.py:352

            # Find existing extension or download if needed
            extension_path = self._find_matlab_extension()
            if extension_path is None:
                log.info("MATLAB extension not found on disk, attempting to download...")
                extension_path = self._download_and_install_matlab_extension()

            if extension_path is None:
                raise RuntimeError(
                    "Failed to locate or download MATLAB Language Server. Please either:\n"
                    "1. Set MATLAB_EXTENSION_PATH environment variable to the MATLAB extension directory\n"
                    "2. Install the MATLAB extension in VS Code (MathWorks.language-matlab)\n"
                    "3. Ensure internet connection for automatic download"
                )

            # Get the language server script path
            server_script = self._get_executable_path(extension_path)

            if not os.path.exists(server_script):
                raise RuntimeError(f"MATLAB Language Server script not found at: {server_script}")

            # Build the command to run the language server
            # The MATLAB language server is run via Node.js with the --stdio flag
            cmd = [node_path, server_script, "--stdio"]
            return cmd

        def create_launch_command_env(self) -> dict[str, str]:
            return {
                "MATLAB_INSTALL_PATH": self.get_matlab_path(),
            }

    def _create_base_initialize_params(self) -> dict:
        """Return the initialize params for the MATLAB Language Server."""
        initialize_params = {
            "locale": "en",
            "capabilities": {
                "textDocument": {
                    "synchronization": {"didSave": True, "dynamicRegistration": True},

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Reinstall/re-download the MATLAB extension so the full script layout exists
  2. Point MATLAB_EXTENSION_PATH at a verified, complete extension directory containing the server script
  3. List the extension directory to confirm the exact script path the integration computes exists

Example fix

# before
export MATLAB_EXTENSION_PATH=/tmp/partial-extract   # script missing
# after
export MATLAB_EXTENSION_PATH=~/.vscode/extensions/MathWorks.language-matlab-1.4.0
Defensive patterns

Strategy: validation

Validate before calling

import os
server_script = os.path.join(os.environ["MATLAB_EXTENSION_PATH"], "dist", "index.js")
assert os.path.exists(server_script), f"missing server script: {server_script}"

Type guard

def script_exists(path: str) -> bool:
    return os.path.isfile(path)

Try / catch

try:
    ls = SolidLSP("matlab")
except RuntimeError as e:
    if "script not found at" in str(e):
        redownload_matlab_extension(); ls = SolidLSP("matlab")
    else:
        raise

Prevention

When it happens

Trigger: _get_executable_path returns a path (e.g. inside the downloaded extension) that is subsequently missing — the extension directory changed/deleted between resolution and check, _get_executable_path returned a computed default path without verifying it, or a partially extracted/corrupted extension download.

Common situations: Interrupted or partial extension download; antivirus/cleanup tooling removing files from the extension dir; custom MATLAB_EXTENSION_PATH whose expected script name differs from what the code builds.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/711c5b0c4d310dc5. Report an issue: GitHub.