{"record":{"id":"3a844cb1c5f82584","repo":"docling-project/docling","slug":"libreoffice-not-found","errorCode":null,"errorMessage":"Libreoffice not found","messagePattern":"Libreoffice not found","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/backend/docx/drawingml/utils.py","lineNumber":42,"sourceCode":"\"\"\"\n\n\ndef get_libreoffice_cmd(raise_if_unavailable: bool = False) -> Optional[str]:\n    \"\"\"Return the libreoffice cmd and optionally test it.\"\"\"\n\n    libreoffice_cmd = (\n        shutil.which(\"libreoffice\")\n        or shutil.which(\"soffice\")\n        or (\n            \"/Applications/LibreOffice.app/Contents/MacOS/soffice\"\n            if os.path.isfile(\"/Applications/LibreOffice.app/Contents/MacOS/soffice\")\n            else None\n        )\n    )\n\n    if raise_if_unavailable:\n        if libreoffice_cmd is None:\n            raise RuntimeError(\"Libreoffice not found\")\n\n        # The following test will raise if the libreoffice_cmd cannot be used\n        subprocess.run(\n            [\n                libreoffice_cmd,\n                \"-h\",\n            ],\n            stdout=subprocess.DEVNULL,\n            stderr=subprocess.DEVNULL,\n            check=True,\n        )\n\n    return libreoffice_cmd\n\n\n@contextmanager\ndef _isolated_libreoffice_profile() -> Iterator[str]:\n    \"\"\"Yield a ``-env:UserInstallation`` argument backed by a throwaway profile.","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/docx/drawingml/utils.py#L24-L60","documentation":"get_libreoffice_cmd(raise_if_unavailable=True) in docling.backend.docx.drawingml.utils raises this RuntimeError when LibreOffice cannot be located: it checks shutil.which('libreoffice'), then shutil.which('soffice'), then the standard macOS .app bundle path. If none is found it refuses to continue; when a command is found it additionally smoke-tests it with '-h' so a broken binary also fails here.","triggerScenarios":"Any docling code path that renders DOCX DrawingML images/drawings via LibreOffice conversion on a machine where libreoffice/soffice is not on PATH and (on macOS) the app is not installed at /Applications/LibreOffice.app. Also when the found binary cannot execute (corrupt install, missing libs) — the subprocess.run(check=True) then raises instead.","commonSituations":"Minimal Docker images (python:slim) without LibreOffice installed; macOS where LibreOffice was installed to a non-default location; CI runners assuming docling's base dependencies include LibreOffice; PATH not propagated in service environments (systemd, cron, containers).","solutions":["Install LibreOffice in the environment: apt-get install -y libreoffice (Debian/Ubuntu), dnf install libreoffice (Fedora), brew install --cask libreoffice (macOS).","Ensure the binary is on PATH for the process that runs docling: which libreoffice || which soffice must succeed; for macOS add /Applications/LibreOffice.app/Contents/MacOS to PATH or install to the default location.","In Docker, install libreoffice (or just libreoffice-impress + libreoffice-core) in the image rather than at runtime.","If LibreOffice is intentionally absent, avoid the DrawingML/shape-conversion code path or make the calling feature optional."],"exampleFix":"# before (Dockerfile)\nFROM python:3.12-slim\nRUN pip install docling\n# convert with drawings -> RuntimeError: Libreoffice not found\n\n# after\nFROM python:3.12-slim\nRUN apt-get update && apt-get install -y --no-install-recommends libreoffice && rm -rf /var/lib/apt/lists/*\nRUN pip install docling","handlingStrategy":"validation","validationCode":"import shutil, os, subprocess\n\ndef libreoffice_available() -> bool:\n    cmd = (shutil.which(\"libreoffice\") or shutil.which(\"soffice\")\n           or (\"/Applications/LibreOffice.app/Contents/MacOS/soffice\"\n               if os.path.isfile(\"/Applications/LibreOffice.app/Contents/MacOS/soffice\") else None))\n    if cmd is None:\n        return False\n    return subprocess.run([cmd, \"-h\"], stdout=subprocess.DEVNULL,\n                          stderr=subprocess.DEVNULL).returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    result = conv.convert(docx_path)\nexcept RuntimeError as e:\n    if \"Libreoffice not found\" in str(e):\n        raise RuntimeError(\"Install LibreOffice (apt-get install -y libreoffice) and ensure soffice is on PATH\") from e\n    raise","preventionTips":["Bake LibreOffice into container images used for drawing-rich Office files.","Add a startup check (shutil.which) in services that convert DOCX/PPTX drawings.","Verify with soffice --version in the same environment that runs docling."],"tags":["libreoffice","environment","dependency","docx","drawingml"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}