tonhowtf/omniget · error · anyhow::Error
não consegui carregar
Error message
não consegui carregar {}: {} What it means
Raised by init() when the ONNX Runtime shared library path was resolved but ort::init_from(path) fails to load the native library (e.g. the file is not a valid shared object, wrong architecture, or missing dependent libs). The error wraps the underlying ort error with the path that failed.
Solutions
- Delete the installed library in the app data dir and reinstall the runtime from the Models screen
- Verify the file is a real shared library for this OS/arch (file onnxruntime.so / otool -L)
- Install OS dependencies the library needs (e.g. libstdc++, glibc)
- Point install_from_path at a known-good lib (e.g. from the pip onnxruntime package)
Example fix
// before
let p = onnxrt::init()?; // "não consegui carregar ...: dlopen failed"
// after
let lib = find_configured_lib();
match std::fs::metadata(&lib) { Ok(m) if m.len() < 1_000_000 => reinstall_runtime().await?, _ => {} }
let p = onnxrt::init()?; Defensive patterns
Strategy: validation
Validate before calling
let ok = std::fs::read(path, ..).map(|b| b.len() > 1_000_000).unwrap_or(false);
Type guard
fn is_likely_elf(p: &Path) -> bool { std::fs::read(p).ok().and_then(|b| b.first().map(|c| *c == 0x7f)).unwrap_or(false) } Try / catch
match onnxrt::init() { Err(e) if e.to_string().contains("não consegui carregar") => { reinstall_runtime().await?; onnxrt::init() } ... } Prevention
- Verify the library size/hash after download before committing
- Install OS native dependencies the runtime links against
- Never hand-edit or truncate the installed library
When it happens
Trigger: init() called with READY unset; resolve_path() returned a path, but ort::init_from(...).commit() fails — file corrupt/truncated, wrong-arch binary, missing transitive dependencies (libc versions, ICU), or a text file masquerading as the lib.
Common situations: Interrupted download leaving a truncated .so; copied a lib from a different OS/arch; pointing config at a stub or LSP file instead of the real library; a partial upgrade replacing the lib with an incompatible version.
Related errors
- não criei o builder de sessão ONNX
- o ONNX Runtime ainda não está instalado. Instale pela tela…
- não existe build oficial do ONNX Runtime para este sistema…
- o pacote não traz nenhuma biblioteca do ONNX Runtime em lib/
- tarefa de extração falhou
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/3408aa9b48c56c36.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/onnxrt.rs:289
}
}
/// Caminho que o `ort` já está usando, quando o carregamento deu certo uma vez.
static READY: OnceLock<PathBuf> = OnceLock::new();
/// Aponta o `ort` para a lib resolvida. Idempotente: o `ort` guarda o handle
/// num `OnceLock` próprio, então a segunda chamada não troca nada — por isso
/// guardamos o caminho que venceu e devolvemos ele.
///
/// Falta de lib vira erro acionável, nunca panic: o `ort` só entra em pânico
/// se alguém tocar na API dele sem passar por aqui.
pub fn init() -> anyhow::Result<PathBuf> {
if let Some(p) = READY.get() {
return Ok(p.clone());
}
let path = resolve_path().ok_or_else(missing_runtime_error)?;
ort::init_from(&path)
.map_err(|e| anyhow!("não consegui carregar {}: {}", path.display(), e))?
.with_name("omniget")
.commit();
let _ = READY.set(path.clone());
Ok(path)
}
fn sha256_of(path: &Path) -> anyhow::Result<String> {
use sha2::{Digest, Sha256};
let mut file = std::fs::File::open(path)
.with_context(|| format!("abrindo {} para conferir o sha256", path.display()))?;
let mut hasher = Sha256::new();
let mut buf = vec![0u8; 1 << 20];
loop {
let n = file.read(&mut buf)?;
if n == 0 {
break;
}
hasher.update(&buf[..n]);View on GitHub (pinned to 8600b91f42)