{"record":{"id":"6a4a42254e5364d7","repo":"oraios/serena","slug":"opam-is-not-installed-or-not-in-path-please-insta","errorCode":null,"errorMessage":"OPAM is not installed or not in PATH.\nPlease install OPAM from: https://opam.ocaml.org/doc/Install.html\n\nInstallation instructions:\n  - macOS: brew install opam\n  - Ubuntu/Debian: sudo apt install opam\n  - Fedora: sudo dnf install opam\n  - Windows: https://fdopen.github.io/opam-repository-mingw/installation/\n\nAfter installation, initialize OPAM with: opam init","messagePattern":"OPAM is not installed or not in PATH\\.\nPlease install OPAM from: https://opam\\.ocaml\\.org/doc/Install\\.html\n\nInstallation instructions:\n  - macOS: brew install opam\n  - Ubuntu/Debian: sudo apt install opam\n  - Fedora: sudo dnf install opam\n  - Windows: https://fdopen\\.github\\.io/opam-repository-mingw/installation/\n\nAfter installation, initialize OPAM with: opam init","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/ocaml_lsp_server.py","lineNumber":45,"sourceCode":"class OcamlLanguageServer(SolidLanguageServer):\n    \"\"\"\n    Provides OCaml and Reason specific instantiation of the SolidLanguageServer class.\n    Contains various configurations and settings specific to OCaml and Reason.\n    \"\"\"\n\n    _ocaml_version: tuple[int, int, int]\n    _lsp_version: tuple[int, int, int]\n    _index_built: bool\n\n    # Minimum LSP version for reliable cross-file references\n    MIN_LSP_VERSION_FOR_CROSS_FILE_REFS: tuple[int, int, int] = (1, 23, 0)\n\n    @staticmethod\n    def _ensure_opam_installed() -> None:\n        \"\"\"Ensure OPAM is installed and available.\"\"\"\n        opam_path = shutil.which(\"opam\")\n        if opam_path is None:\n            raise RuntimeError(\n                \"OPAM is not installed or not in PATH.\\n\"\n                \"Please install OPAM from: https://opam.ocaml.org/doc/Install.html\\n\\n\"\n                \"Installation instructions:\\n\"\n                \"  - macOS: brew install opam\\n\"\n                \"  - Ubuntu/Debian: sudo apt install opam\\n\"\n                \"  - Fedora: sudo dnf install opam\\n\"\n                \"  - Windows: https://fdopen.github.io/opam-repository-mingw/installation/\\n\\n\"\n                \"After installation, initialize OPAM with: opam init\"\n            )\n\n    @staticmethod\n    def _detect_ocaml_version(repository_root_path: str) -> tuple[int, int, int]:\n        \"\"\"\n        Detect and return the OCaml version as a tuple (major, minor, patch).\n        Also checks for version compatibility with ocaml-lsp-server.\n        Raises RuntimeError if version cannot be determined.\n        \"\"\"\n        try:","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/ocaml_lsp_server.py#L27-L63","documentation":"This RuntimeError is raised when the 'opam' executable cannot be found on PATH, which is a hard prerequisite for the ocaml-lsp-server integration. _ensure_opam_installed calls shutil.which('opam') during server __init__ and fails fast with platform-specific install instructions. Language server startup is aborted.","triggerScenarios":"Constructing the OCaml language server on a machine where opam is not installed, or installed but not on the PATH of the process running the library (e.g. missing from CI image, IDE-spawned process env, or non-interactive shell).","commonSituations":"Fresh Docker/CI container without opam; opam installed under ~/.opam or via a user-local toolchain not added to PATH in non-login shells; Windows without the opam mingw installer; macOS without brew install opam.","solutions":["Install opam per platform: brew install opam (macOS), sudo apt install opam (Ubuntu/Debian), sudo dnf install opam (Fedora), or the Windows mingw installer.","Run 'opam init' after installing to initialize the opam root.","Ensure the opam binary directory is on PATH for the process that launches the language server (eval $(opam env) or export PATH).","Verify with 'which opam' in the same shell/environment that runs the code."],"exampleFix":"// before: subprocess env lacks opam\n// after (shell)\neval $(opam env)   # or: export PATH=\"$HOME/.opam/default/bin:$PATH\"\npython -c \"import mylib; mylib.OcamlLsp(...)\"","handlingStrategy":"validation","validationCode":"import shutil\n\ndef require_opam() -> str:\n    opam = shutil.which(\"opam\")\n    if opam is None:\n        raise RuntimeError(\n            \"opam not on PATH. Install: https://opam.ocaml.org/doc/Install.html \"\n            \"and run 'opam init'\"\n        )\n    return opam","typeGuard":null,"tryCatchPattern":"try:\n    server = OcamlLanguageServer(**kwargs)\nexcept RuntimeError as e:\n    if \"OPAM is not installed\" in str(e):\n        raise EnvironmentError(\n            \"OCaml toolchain prerequisite missing. Run the documented opam install \"\n            \"for your platform, then 'opam init'.\"\n        ) from e\n    raise","preventionTips":["Run 'which opam' in the exact environment (CI job, IDE-spawned shell) that will start the server.","Include opam in Dockerfiles/CI images and run 'opam init' during build.","Remember non-login shells skip ~/.profile; set PATH in the launcher, not just dotfiles.","Document the opam prerequisite next to the library usage in your repo."],"tags":["ocaml","opam","missing-binary","environment"],"backgroundTag":"missing-env-var","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}