Stirling-Tools/Stirling-PDF · error · RuntimeError

Command failed

Error message

Command {' '.join(cmd)} failed: {result.stderr}

What it means

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.

Solutions

  1. Install the required external tool (poppler-utils provides pdffonts).
  2. Verify the tool is on PATH: which pdffonts.
  3. Read the included stderr for the tool-specific failure reason.
  4. Validate input PDFs are readable before passing them to the tool.
Defensive patterns

Strategy: validation

Validate before calling

# Ensure the external tool is available before running
import shutil
if not shutil.which("pdffonts"):
    raise SystemExit("pdffonts not found. Install poppler-utils.")

Try / catch

try:
    out = run(cmd, cwd=cwd)
except RuntimeError as exc:
    print(f"[WARN] {exc}", file=sys.stderr)
    continue

Prevention

When it happens

Trigger: 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.

Common situations: pdffonts/poppler not installed. PATH does not include the tool in the current environment. Corrupt PDF that pdffonts cannot read.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/ec144f337cefbeb1. Report an issue: GitHub.

Appendix: source

Thrown at scripts/index_type3_catalogue.py:13

#!/usr/bin/env python3
"""Build a Type3 font catalogue from sample PDFs."""

import argparse
import json
import subprocess
from pathlib import Path


def run(cmd, cwd=None):
    result = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
    if result.returncode != 0:
        raise RuntimeError(f"Command {' '.join(cmd)} failed: {result.stderr}")
    return result.stdout


def parse_pdffonts(output):
    lines = output.splitlines()
    entries = []
    for line in lines[2:]:
        if not line.strip():
            continue
        parts = line.split()
        if "Type" not in parts:
            continue
        idx = parts.index("Type")
        type_value = parts[idx + 1] if idx + 1 < len(parts) else ""
        if not type_value.startswith("3"):
            continue
        font_name = parts[0]
        encoding = parts[-2] if len(parts) >= 2 else ""

View on GitHub (pinned to 9ef20dcab8)