tonhowtf/omniget · error
tesseract falhou: {}
Error message
tesseract falhou: {} What it means
This error is raised when an external `tesseract` OCR process exits with a non-zero status while converting images to a searchable PDF. The library captures tesseract's stderr, trims it, and embeds it in the message so the underlying OCR failure reason is visible. Any failure of the spawned tesseract CLI (bad language packs, unreadable images, out-of-memory) surfaces here.
Solutions
- Run the same tesseract command manually to see the raw stderr
- Install the required tesseract language packs (e.g. `tesseract-ocr-por`)
- Verify tesseract is installed and on PATH (`tesseract --version`)
- Lower `--dpi` or split large documents into smaller batches
- Ensure input images are valid and readable by the process user
Example fix
// before: fails when language pack missing
.args(["-l", "por", "--dpi", "300", "pdf"])
// after: check available langs first and fall back to eng
let langs = if langs_available("por") { "por" } else { "eng" };
.args(["-l", langs, "--dpi", "300", "pdf"]) Defensive patterns
Strategy: try-catch
Validate before calling
// Rust: check tesseract availability and language pack before calling
let ok = tokio::process::Command::new("tesseract")
.args(["--list-langs"]).output().await
.map(|o| o.status.success()).unwrap_or(false);
if !ok { return Err(anyhow!("tesseract indisponivel")); } Try / catch
match run_ocr_to_pdf(&img, &langs, dpi).await {
Ok(pdf) => pdf,
Err(e) if e.to_string().contains("tesseract falhou") => {
eprintln!("OCR falhou: {e}"); fallback_no_ocr()
}
Err(e) => return Err(e),
} Prevention
- Verify tesseract and required language packs are installed at app startup
- Pin and document the tesseract version your app was tested with
- Validate dpi and language codes before spawning the process
- Surface tesseract stderr directly to users instead of a generic message
When it happens
Trigger: Calling the OCR-to-PDF flow with tesseract installed but the requested `-l` language data missing, corrupted/unsupported input images, invalid `--dpi` values, or the tesseract binary crashing mid-run.
Common situations: Missing tesseract language packs (e.g. `por.traineddata` not installed), tesseract not on PATH in CI containers, very large scans exceeding memory, or passing an unsupported language code.
Related errors
- tesseract nao esta instalado
- tesseract falhou em {}: {}
- tesseract nao esta instalado
- {}
- Failed to parse ffprobe JSON: {}
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/8d5f881cf9c0abbe.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf.rs:1286
let list = work.join("pages.txt");
std::fs::write(
&list,
pngs.iter()
.map(|p| p.to_string_lossy().to_string())
.collect::<Vec<_>>()
.join("\n"),
)?;
let base = work.join("ocr");
report(&progress, "ocr", 0, Some(pages as u64), Some(langs.clone()));
let o = crate::core::process::command(&tesseract)
.arg(&list)
.arg(&base)
.args(["-l", &langs, "--dpi", &dpi.to_string(), "pdf"])
.output()
.await?;
if !o.status.success() {
let _ = std::fs::remove_dir_all(&work);
return Err(anyhow!(
"tesseract falhou: {}",
String::from_utf8_lossy(&o.stderr).trim()
));
}
let produced = base.with_extension("pdf");
let output = unique(
out_dir_for(&input_path, &output_dir).join(format!("{} (OCR).pdf", stem(&input_path))),
);
if let Some(parent) = output.parent() {
std::fs::create_dir_all(parent)?;
}
if std::fs::rename(&produced, &output).is_err() {
std::fs::copy(&produced, &output)?;
}
let bytes = std::fs::metadata(&output).map(|m| m.len()).unwrap_or(0);
let _ = std::fs::remove_dir_all(&work);
report(&progress, "done", pages as u64, Some(pages as u64), None);
Ok(PdfOut {View on GitHub (pinned to 8600b91f42)