{"record":{"id":"dbe28b6397fc0880","repo":"ocrmypdf/OCRmyPDF","slug":"the-program-program-did-not-report-its-version","errorCode":null,"errorMessage":"The program '{program}' did not report its version. Message was:\n{output}","messagePattern":"The program '(.+?)' did not report its version\\. Message was:\n(.+?)","errorType":"exception","errorClass":"MissingDependencyError","httpStatus":null,"severity":"error","filePath":"src/ocrmypdf/subprocess/_version.py","lineNumber":74,"sourceCode":"        if e.returncode != 0:\n            log.exception(e)\n            raise MissingDependencyError(\n                f\"Ran program '{program}' but it exited with an error:\\n{e.output}\"\n            ) from e\n        raise MissingDependencyError(\n            f\"Could not find program '{program}' on the PATH\"\n        ) from e\n\n    # Some tools (e.g. veraPDF launched on a recent JDK) print warnings before\n    # the version line, so scan each line rather than only the start of output.\n    version = None\n    for line in output.splitlines():\n        match = re.match(regex, line.strip())\n        if match:\n            version = match.group(1)\n            break\n    if version is None:\n        raise MissingDependencyError(\n            f\"The program '{program}' did not report its version. \"\n            f\"Message was:\\n{output}\"\n        )\n\n    return version\n","sourceCodeStart":56,"sourceCodeEnd":80,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/subprocess/_version.py#L56-L80","documentation":"The program ran successfully but none of its output lines matched the version regex passed to get_version(). The full output is included in the message to aid diagnosis.","triggerScenarios":"get_version(program, regex=...) where the regex doesn't match any line — e.g. the tool changed its banner format between versions, or warnings were printed instead of a version line.","commonSituations":"Upgrading tesseract/qpdf/ghostscript changes version-string format; locale settings altering output; custom plugin tools with unexpected banners;veraPDF JDK warnings preceding output (the code scans all lines for this reason).","solutions":["Run the tool's version command manually and adjust the regex to match actual output","Anchor loosely (e.g. r'([0-9]+\\.[0-9]+\\.[0-9]+)') if only the number matters","Pin/downgrade the tool version whose output your regex was written for","For plugin tools, emit a predictable version line"],"exampleFix":"# before\nv = get_version('tesseract', regex=r'tesseract v(.*)')  # newer builds print differently\n# after\nv = get_version('tesseract', regex=r'tesseract[- ]v?(\\d[\\w.\\-]*)')","handlingStrategy":"validation","validationCode":"import subprocess\\nout = subprocess.run([program, '--version'], capture_output=True, text=True).stdout\\nimport re\\nassert re.search(regex, out), f'regex does not match tool output: {out!r}'; ","typeGuard":null,"tryCatchPattern":"try:\\n    v = get_version(program, regex=rx)\\nexcept MissingDependencyError:\\n    print_actual_output_to_tune_regex(program)","preventionTips":["Write loose version regexes matching digits, not full banners","Re-check regexes after upgrading external tools","Print the tool's real output when writing plugin version checks"],"tags":["dependency","version-check","regex-mismatch","external-tool"],"backgroundTag":"version-string-parse-failed","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}