tonhowtf/omniget · error

LibreOffice nao converteu

Error message

LibreOffice nao converteu {}: {}

What it means

Raised when the spawned `soffice --convert-to` command either exits non-zero or does not produce the expected output file. The message includes the input filename and LibreOffice's stderr (or stdout if stderr is empty), since LibreOffice sometimes reports failures only on stdout.

Solutions

  1. Run the exact soffice command manually to read the real error
  2. Ensure no other soffice instance is running (kill lingering processes / use `-env:UserInstallation` per run)
  3. Verify the input document opens correctly in LibreOffice or another viewer
  4. Check write permission on the output directory
  5. Retries sequentially instead of in parallel to avoid profile lock contention

Example fix

// before: parallel calls collide on the soffice profile lock
let results = join_all(files.iter().map(|f| convert_one(f, "pdf"))).await;
// after: serialize conversions
let mut results = vec![];
for f in &files { results.push(convert_one(f, "pdf").await?); }
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust: pre-check input readability and no lingering soffice lock
let readable = tokio::fs::metadata(input).await.map(|m| !m.len().eq(&0)).unwrap_or(false);
if !readable { return Err(anyhow!("entrada invalida: {}", input)); }

Try / catch

match convert_one(input, target).await {
    Ok(out) => out,
    Err(e) if e.to_string().contains("LibreOffice nao converteu") => {
        eprintln!("{e}"); retry_with_fresh_profile(input, target).await
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: soffice runs but fails to convert a given input (corrupt/encrypted source document, unsupported source variant), a concurrent soffice instance holds the user profile lock, or the output filename differs from the expected `<stem>.<target>`.

Common situations: Password-protected or DRM'd documents, running multiple conversions in parallel under the same user profile (`soffice` singleton lock), read-only output directory, filename stems containing characters LibreOffice rewrites.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf.rs:1359

        std::fs::create_dir_all(&dir)?;
        let is_pdf = input_path
            .extension()
            .map(|e| e.eq_ignore_ascii_case("pdf"))
            .unwrap_or(false);
        let mut cmd = crate::core::process::command(&soffice);
        cmd.args(["--headless", "--norestore"]);
        if is_pdf && target != "pdf" {
            cmd.arg("--infilter=writer_pdf_import");
        }
        cmd.arg("--convert-to")
            .arg(&target)
            .arg("--outdir")
            .arg(&dir)
            .arg(&input_path);
        let o = cmd.output().await?;
        let produced = dir.join(format!("{}.{}", stem(&input_path), target));
        if !o.status.success() || !produced.exists() {
            return Err(anyhow!(
                "LibreOffice nao converteu {}: {}",
                input,
                String::from_utf8_lossy(if o.stderr.is_empty() {
                    &o.stdout
                } else {
                    &o.stderr
                })
                .trim()
            ));
        }
        outputs.push(produced.to_string_lossy().to_string());
    }
    report(&progress, "done", n, Some(n), None);
    Ok(outputs)
}

// ── Leitura posicionada (base do PDF → Markdown) ───────────────────────

View on GitHub (pinned to 8600b91f42)