{"record":{"id":"793fcd09f221ef8b","repo":"tonhowtf/omniget","slug":"ghostscript-n-o-encontrado-nesta-m-quina","errorCode":null,"errorMessage":"Ghostscript não encontrado nesta máquina","messagePattern":"Ghostscript não encontrado nesta máquina","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_repair.rs","lineNumber":465,"sourceCode":"        .file_stem()\n        .map(|s| s.to_string_lossy().to_string())\n        .unwrap_or_else(|| \"documento\".into());\n    let suffix = if opts.suffix.is_empty() {\n        \"-reparado\"\n    } else {\n        opts.suffix.as_str()\n    };\n    Ok(dir.join(format!(\"{}{}.pdf\", stem, suffix)))\n}\n\npub async fn run(opts: RepairOptions, progress: super::ProgressFn) -> anyhow::Result<RepairResult> {\n    let gs = if opts.mode == \"rebuild\" {\n        None\n    } else {\n        super::pdf::find_gs().await\n    };\n    if opts.mode == \"gs\" && gs.is_none() {\n        return Err(anyhow!(\"Ghostscript não encontrado nesta máquina\"));\n    }\n    let total = opts.inputs.len() as u64;\n    let mut items = Vec::new();\n\n    for (i, input) in opts.inputs.iter().enumerate() {\n        super::report(\n            &progress,\n            \"pdf-repair\",\n            \"progress\",\n            i as u64,\n            Some(total),\n            Some(input.clone()),\n        );\n        let inp = Path::new(input);\n        let bytes_before = std::fs::metadata(inp).map(|m| m.len()).unwrap_or(0);\n        let pages_before = open_pages(input).await;\n        let mut item = RepairItem {\n            input: input.clone(),","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_repair.rs#L447-L483","documentation":"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.","triggerScenarios":"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).","commonSituations":"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`.","solutions":["Install Ghostscript and ensure the executable is on PATH (`gs --version` must succeed)","On Windows, install Ghostscript and add its bin dir (gswin64c.exe) to PATH, or set whatever env/override find_gs honors","Use mode \"rebuild\" instead, which needs no Ghostscript","In CI/Docker, add ghostscript to the image before running the tool"],"exampleFix":"// before\npdf_repair::run(RepairOptions { mode: \"gs\".into(), ..opts }, progress).await?;\n// after\nif super::pdf::find_gs().await.is_none() {\n    eprintln!(\"Ghostscript ausente; usando modo rebuild\");\n    opts.mode = \"rebuild\".into();\n}\npdf_repair::run(opts, progress).await?;","handlingStrategy":"fallback","validationCode":"// Rust: resolve Ghostscript before choosing the mode\nlet gs_available = super::pdf::find_gs().await.is_some();\nif opts.mode == \"gs\" && !gs_available {\n    eprintln!(\"Ghostscript ausente; caindo para modo rebuild\");\n    opts.mode = \"rebuild\".into();\n}","typeGuard":"fn gs_mode_supported(mode: &str, gs: &Option<std::path::PathBuf>) -> bool {\n    mode != \"gs\" || gs.is_some()\n}","tryCatchPattern":"match pdf_repair::run(opts, progress).await {\n    Err(e) if e.to_string().contains(\"Ghostscript não encontrado\") => {\n        opts.mode = \"rebuild\".into();\n        pdf_repair::run(opts, progress).await\n    }\n    other => other,\n}","preventionTips":["Probe find_gs() once at startup and expose a capability flag in the UI/CLI","Document the Ghostscript requirement in install docs; add it to CI/Docker images","Default to mode \"rebuild\" unless the user explicitly opts into gs","On Windows verify the gswin64c binary name variant is detected"],"tags":["rust","ghostscript","missing-dependency","environment"],"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"}