tonhowtf/omniget · error
ghostscript nao iniciou
Error message
ghostscript nao iniciou: {} What it means
This error is thrown in run_ghostscript when the tokio async child-process spawn of the Ghostscript executable fails, i.e. `.output()` returns Err before gs even runs. It wraps the underlying io::Error (typically NotFound for a missing binary, or permission/exec issues). It is a pre-execution failure, distinct from Ghostscript running but producing no output.
Solutions
- Install Ghostscript (apt install ghostscript / brew install ghostscript / choco install ghostscript) and ensure it is on PATH
- Verify the resolved gs path manually: run `<gs_path> --version`; fix find_gs detection or the PATH if it fails
- Check the binary is executable (chmod +x / reinstall); confirm no AV policy blocks spawning it
- If you don't need Ghostscript, switch the repair mode to "rebuild" which does not use gs
Example fix
// before
let gs = super::pdf::find_gs().await.unwrap(); // panics or passes stale path
// after
let gs = match super::pdf::find_gs().await {
Some(p) if std::process::Command::new(&p).arg("--version").output().is_ok() => p,
_ => return Err(anyhow!("Ghostscript não encontrado ou não executável")),
}; Defensive patterns
Strategy: fallback
Validate before calling
// Rust: check the gs binary is spawnable before requesting mode "gs"
let ok = match super::pdf::find_gs().await {
Some(p) => tokio::process::Command::new(&p).arg("--version").output().await.is_ok(),
None => false,
};
if !ok { anyhow::bail!("Ghostscript indisponível; use mode=\"rebuild\""); } Type guard
fn gs_spawnable(path: &std::path::Path) -> bool {
path.is_file() && std::process::Command::new(path).arg("--version").output().map(|o| o.status.success()).unwrap_or(false)
} Try / catch
match run(opts, progress).await {
Err(e) if e.to_string().contains("ghostscript nao iniciou") => {
// fall back to mode "rebuild" (no Ghostscript needed)
opts.mode = "rebuild".into();
run(opts, progress).await
}
other => other,
} Prevention
- Install Ghostscript in every environment (dev, CI, Docker) where mode "gs" may be used
- Verify with `gs --version` before shipping pipelines that depend on it
- On Windows ensure gswin64c is on PATH, not just the Ghostscript GUI
- Prefer mode "rebuild" when external dependencies are undesirable
When it happens
Trigger: Calling pdf_repair with mode "gs" (or a mode that reaches run_ghostscript) where the path resolved by super::pdf::find_gs() is stale or not executable; the gs binary was uninstalled or moved after detection; PATH lookup fails at spawn time; OS-level exec permission denied.
Common situations: Ghostscript not installed; gs installed under a name/path find_gs does not check (e.g. Windows gswin64c vs gs); a broken symlink; antivirus blocking execution; running in a container image without ghostscript package.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/9342c4a6f9d1e3e6.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf_repair.rs:429
// ── Orquestração ───────────────────────────────────────────────────────
async fn open_pages(path: &str) -> Option<usize> {
let p = path.to_string();
tokio::task::spawn_blocking(move || super::pdf::info(&p, None).ok().map(|i| i.pages))
.await
.ok()
.flatten()
}
async fn run_ghostscript(gs: &Path, input: &Path, output: &Path) -> anyhow::Result<()> {
let out = crate::core::process::command(gs)
.args(["-q", "-dNOPAUSE", "-dBATCH", "-sDEVICE=pdfwrite"])
.arg(format!("-sOutputFile={}", output.display()))
.arg(input)
.output()
.await
.map_err(|e| anyhow!("ghostscript nao iniciou: {}", e))?;
if !output.exists() || std::fs::metadata(output).map(|m| m.len()).unwrap_or(0) == 0 {
return Err(anyhow!(
"ghostscript não gerou nada: {}",
String::from_utf8_lossy(&out.stderr).trim()
));
}
Ok(())
}
fn output_path(opts: &RepairOptions, inp: &Path) -> anyhow::Result<PathBuf> {
let dir = if opts.output_dir.trim().is_empty() {
inp.parent().map(|p| p.to_path_buf()).unwrap_or_default()
} else {
PathBuf::from(opts.output_dir.trim())
};
std::fs::create_dir_all(&dir)?;
let stem = inp
.file_stem()View on GitHub (pinned to 8600b91f42)