{"record":{"id":"aacc015db118e531","repo":"oraios/serena","slug":"ocaml-lsp-server-executable-not-found-at-executab","errorCode":null,"errorMessage":"ocaml-lsp-server executable not found at {executable_path}","messagePattern":"ocaml-lsp-server executable not found at (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/ocaml_lsp_server.py","lineNumber":200,"sourceCode":"                    capture_output=True,\n                    text=True,\n                    cwd=repository_root_path,\n                    **subprocess_kwargs(),\n                )\n                executable_path = result.stdout.strip().split(\"\\n\")[0]\n            else:\n                result = subprocess_run(\n                    [\"opam\", \"exec\", \"--\", \"which\", \"ocamllsp\"],\n                    check=True,\n                    capture_output=True,\n                    text=True,\n                    cwd=repository_root_path,\n                    **subprocess_kwargs(),\n                )\n                executable_path = result.stdout.strip()\n\n            if not os.path.exists(executable_path):\n                raise RuntimeError(f\"ocaml-lsp-server executable not found at {executable_path}\")\n\n            if platform.system() != \"Windows\":\n                os.chmod(executable_path, os.stat(executable_path).st_mode | stat.S_IEXEC)\n\n            return executable_path\n\n        except subprocess.CalledProcessError as e:\n            raise RuntimeError(\n                f\"Failed to find ocaml-lsp-server executable.\\n\"\n                f\"Command failed: {e.cmd}\\n\"\n                f\"Return code: {e.returncode}\\n\"\n                f\"Stderr: {e.stderr}\\n\\n\"\n                \"This usually means ocaml-lsp-server is not installed or not in PATH.\\n\"\n                \"Try:\\n\"\n                \"  1. Check opam switch: opam switch show\\n\"\n                \"  2. Install ocaml-lsp-server: opam install ocaml-lsp-server\\n\"\n                \"  3. Ensure opam env is activated: eval $(opam env)\"\n            )","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/ocaml_lsp_server.py#L182-L218","documentation":"Raised after the library resolves the ocamllsp executable path via opam (`opam var`/`opam exec -- where`) but `os.path.exists(executable_path)` is False. The check step succeeded yet the binary file is absent at the reported location, so the language server cannot be launched.","triggerScenarios":"Instantiating OcamlLSPServer when `opam exec -- where ocamllsp` (Windows) or the Unix lookup returns a path that does not exist — e.g. empty stdout stripped to '', a stale opam switch, or a package installed but binary removed.","commonSituations":"Empty or stale switch after `opam update`/switch removal; `where` returning an empty string on misconfigured opam; package registered but files pruned; symlink to a removed target; Windows path resolution returning a nonexistent location.","solutions":["Run `eval $(opam env) && which ocamllsp` to see where the binary actually resolves and whether it exists.","Reinstall the package: `opam reinstall ocaml-lsp-server` to recreate missing binaries.","Verify the active switch is intact: `opam switch show`, `opam switch repair` if corrupted.","Check that stdout of the lookup command isn't empty (empty path means opam can't locate ocamllsp — reinstall the package)."],"exampleFix":"// before (shell)\nopam switch myswitch  # switch broken, binary missing\n// after\nopam switch repair && eval $(opam env) && opam reinstall ocaml-lsp-server\nwhich ocamllsp  # verify path exists before starting server","handlingStrategy":"validation","validationCode":"import subprocess, os\ndef ocamllsp_binary_present():\n    r = subprocess.run([\"opam\", \"exec\", \"--\", \"where\", \"ocamllsp\"], capture_output=True, text=True)\n    path = r.stdout.strip()\n    return bool(path) and os.path.exists(path)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `opam reinstall ocaml-lsp-server` after switch changes","Confirm `which ocamllsp` resolves to an existing file preflight","Repair switches with `opam switch repair` after opam upgrades","Don't prune ~/.opam directories while a switch is active"],"tags":["ocaml","opam","executable-not-found","filesystem"],"backgroundTag":"executable-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}