tonhowtf/omniget · error

Ghostscript não encontrado nesta máquina

Error message

Ghostscript não encontrado nesta máquina

What it means

Validation error from pdf_repair::run: the caller requested mode "gs" (Ghostscript-based repair) but super::pdf::find_gs() could not locate a Ghostscript executable on this machine. The library refuses to proceed rather than silently falling back to another method.

Solutions

  1. Install Ghostscript and ensure the executable is on PATH (`gs --version` must succeed)
  2. On Windows, install Ghostscript and add its bin dir (gswin64c.exe) to PATH, or set whatever env/override find_gs honors
  3. Use mode "rebuild" instead, which needs no Ghostscript
  4. In CI/Docker, add ghostscript to the image before running the tool

Example fix

// before
pdf_repair::run(RepairOptions { mode: "gs".into(), ..opts }, progress).await?;
// after
if super::pdf::find_gs().await.is_none() {
    eprintln!("Ghostscript ausente; usando modo rebuild");
    opts.mode = "rebuild".into();
}
pdf_repair::run(opts, progress).await?;
Defensive patterns

Strategy: fallback

Validate before calling

// Rust: resolve Ghostscript before choosing the mode
let gs_available = super::pdf::find_gs().await.is_some();
if opts.mode == "gs" && !gs_available {
    eprintln!("Ghostscript ausente; caindo para modo rebuild");
    opts.mode = "rebuild".into();
}

Type guard

fn gs_mode_supported(mode: &str, gs: &Option<std::path::PathBuf>) -> bool {
    mode != "gs" || gs.is_some()
}

Try / catch

match pdf_repair::run(opts, progress).await {
    Err(e) if e.to_string().contains("Ghostscript não encontrado") => {
        opts.mode = "rebuild".into();
        pdf_repair::run(opts, progress).await
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling run(RepairOptions { mode: "gs", .. }) on a machine where Ghostscript is not installed, not on PATH, or installed under a binary name find_gs doesn't probe (e.g. gswin64c.exe on Windows, or a custom install prefix).

Common situations: Fresh dev machine or CI container without the ghostscript package; macOS after a partial Homebrew cleanup; Windows where only the Ghostscript GUI is installed and gs/gswin64c isn't on PATH; Docker image built without `apt-get install ghostscript`.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/793fcd09f221ef8b. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf_repair.rs:465

        .file_stem()
        .map(|s| s.to_string_lossy().to_string())
        .unwrap_or_else(|| "documento".into());
    let suffix = if opts.suffix.is_empty() {
        "-reparado"
    } else {
        opts.suffix.as_str()
    };
    Ok(dir.join(format!("{}{}.pdf", stem, suffix)))
}

pub async fn run(opts: RepairOptions, progress: super::ProgressFn) -> anyhow::Result<RepairResult> {
    let gs = if opts.mode == "rebuild" {
        None
    } else {
        super::pdf::find_gs().await
    };
    if opts.mode == "gs" && gs.is_none() {
        return Err(anyhow!("Ghostscript não encontrado nesta máquina"));
    }
    let total = opts.inputs.len() as u64;
    let mut items = Vec::new();

    for (i, input) in opts.inputs.iter().enumerate() {
        super::report(
            &progress,
            "pdf-repair",
            "progress",
            i as u64,
            Some(total),
            Some(input.clone()),
        );
        let inp = Path::new(input);
        let bytes_before = std::fs::metadata(inp).map(|m| m.len()).unwrap_or(0);
        let pages_before = open_pages(input).await;
        let mut item = RepairItem {
            input: input.clone(),

View on GitHub (pinned to 8600b91f42)