oraios/serena · error · RuntimeError
Could not parse ocaml-lsp-server version from output: {versi
Error message
Could not parse ocaml-lsp-server version from output: {version_str}
Please ensure ocaml-lsp-server is properly installed:
opam list -i ocaml-lsp-server What it means
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.
Source
Thrown at src/solidlsp/language_servers/ocaml_lsp_server.py:131
try:
result = subprocess_run(
["opam", "list", "-i", "ocaml-lsp-server", "--columns=version", "--short"],
check=True,
capture_output=True,
text=True,
cwd=repository_root_path,
**subprocess_kwargs(),
)
version_str = result.stdout.strip()
version_match = re.search(r"(\d+)\.(\d+)\.(\d+)", version_str)
if version_match:
major = int(version_match.group(1))
minor = int(version_match.group(2))
patch = int(version_match.group(3))
version_tuple = (major, minor, patch)
log.info(f"ocaml-lsp-server version: {major}.{minor}.{patch}")
return version_tuple
raise RuntimeError(
f"Could not parse ocaml-lsp-server version from output: {version_str}\n"
"Please ensure ocaml-lsp-server is properly installed:\n"
" opam list -i ocaml-lsp-server"
)
except subprocess.CalledProcessError as e:
raise RuntimeError(
f"Failed to detect ocaml-lsp-server version: {e.stderr}\nPlease install ocaml-lsp-server:\n opam install ocaml-lsp-server"
) from e
except FileNotFoundError as e:
raise RuntimeError("opam not found. Please install opam:\n https://opam.ocaml.org/doc/Install.html") from e
@staticmethod
def _ensure_ocaml_lsp_installed(repository_root_path: str) -> str:
"""
Ensure ocaml-lsp-server is installed and return the executable path.
Raises RuntimeError with helpful message if not installed.
"""
# Check if ocaml-lsp-server is installedView on GitHub (pinned to 7fcbca7e62)
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.
Example fix
// before (shell) # dev pin with odd version opam pin add ocaml-lsp-server.dev --dev // after opam pin remove ocaml-lsp-server.dev opam install ocaml-lsp-server
Defensive patterns
Strategy: validation
Validate before calling
import re, subprocess
def lsp_version_is_clean() -> str:
r = subprocess.run(
["opam", "list", "--installed", "ocaml-lsp-server"],
capture_output=True, text=True,
)
versions = re.findall(r"\d+\.\d+\.\d+", r.stdout)
if r.returncode != 0 or not versions:
raise RuntimeError(
"ocaml-lsp-server version not detectable; install a stable release: "
"opam install ocaml-lsp-server"
)
return versions[0] Try / catch
try:
server = OcamlLanguageServer(**kwargs)
except RuntimeError as e:
if "Could not parse ocaml-lsp-server version" in str(e):
logger.error("Installed ocaml-lsp-server reports an unparseable version (%s). Reinstall a stable release: opam install ocaml-lsp-server", e)
raise
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- OCaml 5.1.0 is incompatible with ocaml-lsp-server. Please us
- Could not parse OCaml version from output: {result.stdout.st
- Failed to detect ocaml-lsp-server version: {e.stderr} Please
- OPAM is not installed or not in PATH. Please install OPAM fr
- Failed to detect OCaml version: {e.stderr} Please ensure OCa
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/40dadcbef5b351ed.
Report an issue: GitHub.