{"record":{"id":"62e84b8b0e673ffa","repo":"tonhowtf/omniget","slug":"tesseract-nao-esta-instalado-pdf","errorCode":null,"errorMessage":"tesseract nao esta instalado","messagePattern":"tesseract nao esta instalado","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf.rs","lineNumber":1227,"sourceCode":"    let output =\n        unique(out_dir_for(&input, output_dir).join(format!(\"{} (seguro).pdf\", stem(&input))));\n    let dpi = if dpi == 0 { 150 } else { dpi };\n    let quality = if quality == 0 { 85 } else { quality };\n    rasterize(&input, &output, dpi, quality, progress)\n}\n\n// ── OCR (PDF pesquisável) ──────────────────────────────────────────────\n\npub async fn ocr(\n    input: String,\n    langs: String,\n    output_dir: String,\n    dpi: u32,\n    progress: super::ProgressFn,\n) -> anyhow::Result<PdfOut> {\n    let tesseract = super::ocr::locate()\n        .await\n        .ok_or_else(|| anyhow!(\"tesseract nao esta instalado\"))?;\n    let input_path = PathBuf::from(input.trim());\n    let langs = if langs.trim().is_empty() {\n        \"eng\".to_string()\n    } else {\n        langs.trim().to_string()\n    };\n    let dpi = if dpi == 0 { 300 } else { dpi };\n    let work = super::temp_dir().join(format!(\"pdf-ocr-{}\", uuid::Uuid::new_v4()));\n    std::fs::create_dir_all(&work)?;\n\n    // 1) páginas → PNG\n    let (pngs, pages) = {\n        let work = work.clone();\n        let input = input_path.clone();\n        let progress = progress.clone();\n        tokio::task::spawn_blocking(move || -> anyhow::Result<(Vec<PathBuf>, usize)> {\n            let api = api()?;\n            let _g = OPS.lock().unwrap_or_else(|p| p.into_inner());","sourceCodeStart":1209,"sourceCodeEnd":1245,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf.rs#L1209-L1245","documentation":"OCR operations require the tesseract binary; super::ocr::locate() asynchronously searches for it and returns None when absent. The OCR entry point then throws \"tesseract nao esta instalado\" (\"tesseract is not installed\").","triggerScenarios":"Calling the OCR function (input, langs, output_dir, dpi, progress signature) on a system where tesseract is not installed or not discoverable via PATH/standard install locations.","commonSituations":"macOS/Linux machines without tesseract installed; Windows without the UB-Mannheim build or not on PATH; CI containers lacking OCR tooling; users selecting OCR without realizing an external binary is required.","solutions":["Install tesseract (apt install tesseract-ocr / brew install tesseract).","On Windows, install UB-Mannheim tesseract and add its directory to PATH.","Install required language packs (e.g. tesseract-ocr-por) for non-English langs.","Pre-check locate() in the UI and prompt the user to install tesseract before offering OCR."],"exampleFix":"// before\nocr(&OcrOptions { langs: \"por\".into(), .. })\n\n// after\nif super::ocr::locate().await.is_none() {\n    eprintln!(\"install tesseract-ocr to use OCR\");\n} else {\n    ocr(&OcrOptions { langs: \"por\".into(), .. });\n}","handlingStrategy":"validation","validationCode":"async fn tesseract_ready() -> bool {\n    super::ocr::locate().await.is_some()\n}\n// #[tokio::main] context:\n// if !tesseract_ready().await { show_install_hint(); return; }","typeGuard":null,"tryCatchPattern":"match run_ocr(&opts).await {\n    Ok(out) => use(out),\n    Err(e) if e.to_string().contains(\"tesseract nao esta instalado\") => {\n        eprintln!(\"Install tesseract-ocr (and language packs) to enable OCR\");\n    }\n    Err(e) => eprintln!(\"ocr failed: {e}\"),\n}","preventionTips":["Probe super::ocr::locate() at startup and hide/disable OCR features when None.","Install tesseract and needed language packs in installers and Docker images.","On Windows, verify the UB-Mannheim install path is on PATH.","Document the external-binary requirement in the app's setup docs."],"tags":["pdf","ocr","tesseract","missing-binary","rust"],"backgroundTag":"missing-dependency","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}