{"record":{"id":"c44fb0a0f7ce509d","repo":"oraios/serena","slug":"matlab-installation-not-found-set-the-matlab-path","errorCode":null,"errorMessage":"MATLAB installation not found. Set the MATLAB_PATH environment variable to your MATLAB installation directory (e.g., /Applications/MATLAB_R2024b.app on macOS, C:\\Program Files\\MATLAB\\R2024b on Windows, or /usr/local/MATLAB/R2024b on Linux).","messagePattern":"MATLAB installation not found\\. Set the MATLAB_PATH environment variable to your MATLAB installation directory \\(e\\.g\\., /Applications/MATLAB_R2024b\\.app on macOS, C:\\\\Program Files\\\\MATLAB\\\\R2024b on Windows, or /usr/local/MATLAB/R2024b on Linux\\)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/matlab_language_server.py","lineNumber":303,"sourceCode":"                        if os.path.isdir(match):\n                            log.info(f\"Found MATLAB installation: {match}\")\n                            return match\n\n            elif system == \"Linux\":\n                # Check common Linux locations\n                search_patterns = [\n                    \"/usr/local/MATLAB/R*\",\n                    \"/opt/MATLAB/R*\",\n                    os.path.expanduser(\"~/MATLAB/R*\"),\n                ]\n                for pattern in search_patterns:\n                    matches = sorted(glob.glob(pattern), reverse=True)\n                    for match in matches:\n                        if os.path.isdir(match):\n                            log.info(f\"Found MATLAB installation: {match}\")\n                            return match\n\n            raise RuntimeError(\n                f\"MATLAB installation not found. Set the {MATLAB_PATH_ENV_VAR} environment variable \"\n                \"to your MATLAB installation directory (e.g., /Applications/MATLAB_R2024b.app on macOS, \"\n                \"C:\\\\Program Files\\\\MATLAB\\\\R2024b on Windows, or /usr/local/MATLAB/R2024b on Linux).\"\n            )\n\n        def get_matlab_path(self) -> str:\n            \"\"\"Get MATLAB path from settings or auto-detect.\"\"\"\n            if self._matlab_path is not None:\n                return self._matlab_path\n\n            matlab_path = self._custom_settings.get(\"matlab_path\")\n\n            if not matlab_path:\n                matlab_path = self._find_matlab_installation()  # Raises RuntimeError if not found\n\n            # Verify MATLAB path exists\n            if not os.path.isdir(matlab_path):\n                raise RuntimeError(f\"MATLAB installation directory does not exist: {matlab_path}\")","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/matlab_language_server.py#L285-L321","documentation":"The MATLAB integration needs a local MATLAB installation to run the language server. It searches common install locations via glob patterns; if none is found, it raises RuntimeError telling you to set the MATLAB_PATH environment variable explicitly.","triggerScenarios":"create_launch_command -> get_matlab_path with no explicit matlab_path, and _find_matlab_installation finds no directory matching its known patterns (non-standard install location, custom install prefix, or MATLAB not installed at all).","commonSituations":"MATLAB installed outside default paths (e.g. ~/matlab, /opt); multiple MATLAB versions in an unrecognized layout; headless CI containers with no MATLAB installed; typo'd MATLAB_PATH value.","solutions":["Set the MATLAB_PATH environment variable to your MATLAB installation directory (e.g. /Applications/MATLAB_R2024b.app, C:\\Program Files\\MATLAB\\R2024b, /usr/local/MATLAB/R2024b)","Verify the directory you point to actually contains the MATLAB binaries (os.path.isdir must pass)","Install MATLAB if it is not present on the machine"],"exampleFix":"# before\n# (no MATLAB_PATH set)\n# after\nexport MATLAB_PATH=/usr/local/MATLAB/R2024b","handlingStrategy":"validation","validationCode":"import os\nif not os.environ.get(\"MATLAB_PATH\"):\n    for p in (\"/usr/local/MATLAB/R2024b\", \"/Applications/MATLAB_R2024b.app\",\n              \"C:\\\\Program Files\\\\MATLAB\\\\R2024b\"):\n        if os.path.isdir(p):\n            os.environ[\"MATLAB_PATH\"] = p; break\n    else:\n        raise RuntimeError(\"Set MATLAB_PATH before starting the MATLAB language server\")","typeGuard":"def matlab_available(env_var: str = \"MATLAB_PATH\") -> bool:\n    v = os.environ.get(env_var)\n    return bool(v) and os.path.isdir(v)","tryCatchPattern":"try:\n    ls = SolidLSP(\"matlab\")\nexcept RuntimeError as e:\n    if \"MATLAB installation not found\" in str(e):\n        os.environ[\"MATLAB_PATH\"] = discover_matlab_dir()\n        ls = SolidLSP(\"matlab\")\n    else:\n        raise","preventionTips":["Always set MATLAB_PATH explicitly in CI/containers","Re-check the env var after MATLAB version upgrades","Verify the directory exists with os.path.isdir before launching"],"tags":["matlab","environment","missing-install","path"],"backgroundTag":"missing-env-var","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}