{"record":{"id":"f1143f51af8398e0","repo":"oraios/serena","slug":"ocaml-lsp-server-is-not-installed-please-install","errorCode":null,"errorMessage":"ocaml-lsp-server is not installed.\n\nPlease install it with:\n  opam install ocaml-lsp-server\n\nNote: ocaml-lsp-server requires OCaml < 5.1 or >= 5.1.1 (OCaml 5.1.0 is not supported).\nIf you have OCaml 5.1.0, create a new opam switch with a compatible version:\n  opam switch create <name> ocaml-base-compiler.4.14.2\n  opam switch <name>\n  eval $(opam env)\n  opam install ocaml-lsp-server\n\nFor more information: https://github.com/ocaml/ocaml-lsp","messagePattern":"ocaml-lsp-server is not installed\\.\n\nPlease install it with:\n  opam install ocaml-lsp-server\n\nNote: ocaml-lsp-server requires OCaml < 5\\.1 or >= 5\\.1\\.1 \\(OCaml 5\\.1\\.0 is not supported\\)\\.\nIf you have OCaml 5\\.1\\.0, create a new opam switch with a compatible version:\n  opam switch create <name> ocaml-base-compiler\\.4\\.14\\.2\n  opam switch <name>\n  eval \\$\\(opam env\\)\n  opam install ocaml-lsp-server\n\nFor more information: https://github\\.com/ocaml/ocaml-lsp","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/ocaml_lsp_server.py","lineNumber":160,"sourceCode":"\n    @staticmethod\n    def _ensure_ocaml_lsp_installed(repository_root_path: str) -> str:\n        \"\"\"\n        Ensure ocaml-lsp-server is installed and return the executable path.\n        Raises RuntimeError with helpful message if not installed.\n        \"\"\"\n        # Check if ocaml-lsp-server is installed\n        try:\n            result = subprocess_run(\n                [\"opam\", \"list\", \"-i\", \"ocaml-lsp-server\"],\n                check=False,\n                capture_output=True,\n                text=True,\n                cwd=repository_root_path,\n                **subprocess_kwargs(),\n            )\n            if \"ocaml-lsp-server\" not in result.stdout or \"# No matches found\" in result.stdout:\n                raise RuntimeError(\n                    \"ocaml-lsp-server is not installed.\\n\\n\"\n                    \"Please install it with:\\n\"\n                    \"  opam install ocaml-lsp-server\\n\\n\"\n                    \"Note: ocaml-lsp-server requires OCaml < 5.1 or >= 5.1.1 (OCaml 5.1.0 is not supported).\\n\"\n                    \"If you have OCaml 5.1.0, create a new opam switch with a compatible version:\\n\"\n                    \"  opam switch create <name> ocaml-base-compiler.4.14.2\\n\"\n                    \"  opam switch <name>\\n\"\n                    \"  eval $(opam env)\\n\"\n                    \"  opam install ocaml-lsp-server\\n\\n\"\n                    \"For more information: https://github.com/ocaml/ocaml-lsp\"\n                )\n            log.info(\"ocaml-lsp-server is installed\")\n        except subprocess.CalledProcessError as e:\n            raise RuntimeError(f\"Failed to check ocaml-lsp-server installation: {e.stderr}\")\n\n        # Find the executable path\n        try:\n            if platform.system() == \"Windows\":","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/ocaml_lsp_server.py#L142-L178","documentation":"Raised by SolidLSP's OcamlLSPServer._ensure_ocaml_lsp_server (called from __init__) when an `opam list` query run in the repository root shows that the ocaml-lsp-server package is not installed in the current opam switch. The library requires the ocaml-lsp-server binary to start the language server and cannot proceed without it. The message also warns that OCaml 5.1.0 is unsupported by ocaml-lsp-server.","triggerScenarios":"Instantiating OcamlLSPServer when the active opam switch lacks ocaml-lsp-server, or when `opam list` output contains '# No matches found'. Also triggered if opam list succeeds but the package name is absent (e.g. wrong switch selected).","commonSituations":"Fresh OCaml environment or container without the LSP package; developer switched to a new opam switch that doesn't have ocaml-lsp-server; OCaml 5.1.0 switch where the package can't be installed; CI image missing opam packages.","solutions":["Run `opam install ocaml-lsp-server` in the repository root switch.","Check the current switch with `opam switch show`; switch to one with the package: `opam switch <name>` then `eval $(opam env)`.","If on OCaml 5.1.0, create a compatible switch: `opam switch create <name> ocaml-base-compiler.4.14.2` then `eval $(opam env)` and install the package.","Verify with `opam list | grep ocaml-lsp-server` that the package is visible before launching."],"exampleFix":"// before (failing shell)\nopam switch 5.1.0\neval $(opam env)  # ocaml-lsp-server not installable on 5.1.0\n// after\nopam switch create ocaml-414 ocaml-base-compiler.4.14.2\nopam switch ocaml-414\neval $(opam env)\nopam install ocaml-lsp-server","handlingStrategy":"validation","validationCode":"import subprocess\ndef ensure_ocaml_lsp_installed(repo_root):\n    r = subprocess.run([\"opam\", \"list\", \"--\", \"ocaml-lsp-server\"], capture_output=True, text=True, cwd=repo_root)\n    if r.returncode != 0 or \"ocaml-lsp-server\" not in r.stdout or \"# No matches found\" in r.stdout:\n        raise RuntimeError(\"ocaml-lsp-server not installed; run: opam install ocaml-lsp-server\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bake `opam install ocaml-lsp-server` into your Dockerfile/CI setup step","Avoid OCaml 5.1.0 switches (unsupported); pin 4.14.x or >= 5.1.1","Always `eval $(opam env)` before launching the server so the right switch is visible","Verify installation in a preflight check before instantiating the server"],"tags":["ocaml","opam","missing-dependency","environment-setup"],"backgroundTag":"language-server-dependency-missing","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}