{"record":{"id":"ec144f337cefbeb1","repo":"Stirling-Tools/Stirling-PDF","slug":"command-join-cmd-failed-result-stderr","errorCode":null,"errorMessage":"Command {' '.join(cmd)} failed: {result.stderr}","messagePattern":"Command (.+?) failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/index_type3_catalogue.py","lineNumber":13,"sourceCode":"#!/usr/bin/env python3\n\"\"\"Build a Type3 font catalogue from sample PDFs.\"\"\"\n\nimport argparse\nimport json\nimport subprocess\nfrom pathlib import Path\n\n\ndef run(cmd, cwd=None):\n    result = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)\n    if result.returncode != 0:\n        raise RuntimeError(f\"Command {' '.join(cmd)} failed: {result.stderr}\")\n    return result.stdout\n\n\ndef parse_pdffonts(output):\n    lines = output.splitlines()\n    entries = []\n    for line in lines[2:]:\n        if not line.strip():\n            continue\n        parts = line.split()\n        if \"Type\" not in parts:\n            continue\n        idx = parts.index(\"Type\")\n        type_value = parts[idx + 1] if idx + 1 < len(parts) else \"\"\n        if not type_value.startswith(\"3\"):\n            continue\n        font_name = parts[0]\n        encoding = parts[-2] if len(parts) >= 2 else \"\"","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/scripts/index_type3_catalogue.py#L1-L31","documentation":"RuntimeError raised by index_type3_catalogue.run when a subprocess command (pdffonts) exits non-zero. The error message includes the command and its stderr. This wraps any failed external tool invocation used to build the Type3 font catalogue.","triggerScenarios":"The run() helper invokes an external binary (e.g. pdffonts from poppler-utils) with capture_output; a non-zero exit code triggers this. The tool is missing (not on PATH), the input PDF is unreadable, or the tool crashed.","commonSituations":"pdffonts/poppler not installed. PATH does not include the tool in the current environment. Corrupt PDF that pdffonts cannot read.","solutions":["Install the required external tool (poppler-utils provides pdffonts).","Verify the tool is on PATH: which pdffonts.","Read the included stderr for the tool-specific failure reason.","Validate input PDFs are readable before passing them to the tool."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Ensure the external tool is available before running\nimport shutil\nif not shutil.which(\"pdffonts\"):\n    raise SystemExit(\"pdffonts not found. Install poppler-utils.\")","typeGuard":null,"tryCatchPattern":"try:\n    out = run(cmd, cwd=cwd)\nexcept RuntimeError as exc:\n    print(f\"[WARN] {exc}\", file=sys.stderr)\n    continue","preventionTips":["Install required external tools (poppler-utils) and verify PATH.","Read included stderr for tool-specific failures.","Validate input PDFs before invoking external tools."],"tags":["subprocess","scripts","dependencies","python","external-tool"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}