{"record":{"id":"40dadcbef5b351ed","repo":"oraios/serena","slug":"could-not-parse-ocaml-lsp-server-version-from-outp","errorCode":null,"errorMessage":"Could not parse ocaml-lsp-server version from output: {version_str}\nPlease ensure ocaml-lsp-server is properly installed:\n  opam list -i ocaml-lsp-server","messagePattern":"Could not parse ocaml-lsp-server version from output: (.+?)\nPlease ensure ocaml-lsp-server is properly installed:\n  opam list -i ocaml-lsp-server","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/ocaml_lsp_server.py","lineNumber":131,"sourceCode":"        try:\n            result = subprocess_run(\n                [\"opam\", \"list\", \"-i\", \"ocaml-lsp-server\", \"--columns=version\", \"--short\"],\n                check=True,\n                capture_output=True,\n                text=True,\n                cwd=repository_root_path,\n                **subprocess_kwargs(),\n            )\n            version_str = result.stdout.strip()\n            version_match = re.search(r\"(\\d+)\\.(\\d+)\\.(\\d+)\", version_str)\n            if version_match:\n                major = int(version_match.group(1))\n                minor = int(version_match.group(2))\n                patch = int(version_match.group(3))\n                version_tuple = (major, minor, patch)\n                log.info(f\"ocaml-lsp-server version: {major}.{minor}.{patch}\")\n                return version_tuple\n            raise RuntimeError(\n                f\"Could not parse ocaml-lsp-server version from output: {version_str}\\n\"\n                \"Please ensure ocaml-lsp-server is properly installed:\\n\"\n                \"  opam list -i ocaml-lsp-server\"\n            )\n        except subprocess.CalledProcessError as e:\n            raise RuntimeError(\n                f\"Failed to detect ocaml-lsp-server version: {e.stderr}\\nPlease install ocaml-lsp-server:\\n  opam install ocaml-lsp-server\"\n            ) from e\n        except FileNotFoundError as e:\n            raise RuntimeError(\"opam not found. Please install opam:\\n  https://opam.ocaml.org/doc/Install.html\") from e\n\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","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/ocaml_lsp_server.py#L113-L149","documentation":"This RuntimeError is raised when the ocaml-lsp-server version probe succeeds but its output cannot be parsed into a major.minor.patch triple. _detect_lsp_version runs a version query via opam and, if the regex fails on the output string, fails startup with the unparsed text included. The message points to verifying the opam package is installed.","triggerScenarios":"Constructing the OCaml language server when the installed ocaml-lsp-server reports a version string that doesn't match the expected x.y.z pattern: dev/prerelease version suffixes, empty output, or unexpected tooling output from the version command.","commonSituations":"A git/dev build of ocaml-lsp-server with a non-numeric version; the version command producing warnings before the version line; broken or partial opam install returning empty output.","solutions":["Run 'opam list -i ocaml-lsp-server' to confirm the package and its version are properly installed.","If a dev/prerelease build is installed, install a stable release: opam install ocaml-lsp-server.","Reinstall the package to repair partial installs: opam reinstall ocaml-lsp-server.","Ensure the environment is activated (eval $(opam env)) so the correct package metadata is queried."],"exampleFix":"// before (shell)\n# dev pin with odd version\nopam pin add ocaml-lsp-server.dev --dev\n// after\nopam pin remove ocaml-lsp-server.dev\nopam install ocaml-lsp-server","handlingStrategy":"validation","validationCode":"import re, subprocess\n\ndef lsp_version_is_clean() -> str:\n    r = subprocess.run(\n        [\"opam\", \"list\", \"--installed\", \"ocaml-lsp-server\"],\n        capture_output=True, text=True,\n    )\n    versions = re.findall(r\"\\d+\\.\\d+\\.\\d+\", r.stdout)\n    if r.returncode != 0 or not versions:\n        raise RuntimeError(\n            \"ocaml-lsp-server version not detectable; install a stable release: \"\n            \"opam install ocaml-lsp-server\"\n        )\n    return versions[0]","typeGuard":null,"tryCatchPattern":"try:\n    server = OcamlLanguageServer(**kwargs)\nexcept RuntimeError as e:\n    if \"Could not parse ocaml-lsp-server version\" in str(e):\n        logger.error(\"Installed ocaml-lsp-server reports an unparseable version (%s). Reinstall a stable release: opam install ocaml-lsp-server\", e)\n        raise\n    raise","preventionTips":["Prefer stable opam releases over --dev pins for ocaml-lsp-server.","Run 'opam list -i ocaml-lsp-server' as a preflight check in dev setup scripts.","Reinstall the package after partial or interrupted installs (opam reinstall).","Keep the opam repository updated (opam update) so version metadata resolves correctly."],"tags":["ocaml","lsp","version-parse","opam"],"backgroundTag":"version-parse-failed","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}