tonhowtf/omniget · error · anyhow::Error
não é um arquivo
Error message
{} não é um arquivo What it means
Raised by install_from_path() when the user-supplied path is not a regular file (is_file() false): directories, broken symlinks, or nonexistent paths all fail here. The library validates the input early because it will read the file bytes next.
Solutions
- Pass the exact path to the shared library file (e.g. libonnxruntime.so), not its directory
- Check the path exists and is a regular file before calling (std::fs::metadata(path).is_file())
- Resolve symlinks with std::fs::canonicalize before calling
- Re-run the file picker to get a valid selection
Example fix
// before
onnxrt::install_from_path(Path::new("~/Downloads/onnxruntime/"))?; // directory
// after
let p = std::fs::canonicalize("~/Downloads/onnxruntime/lib/libonnxruntime.so")?;
debug_assert!(p.is_file());
onnxrt::install_from_path(&p)?; Defensive patterns
Strategy: type-guard
Validate before calling
if !src.is_file() { return Err(anyhow!("{} is not a file", src.display())); } Type guard
fn is_regular_file(p: &std::path::Path) -> bool { std::fs::metadata(p).map(|m| m.is_file()).unwrap_or(false) } Try / catch
match onnxrt::install_from_path(&p) { Err(e) if e.to_string().contains("não é um arquivo") => show_file_picker_again(), ... } Prevention
- Canonicalize user-supplied paths before calling
- Use a file dialog restricted to library file types
- Reject directory picks in the UI layer
When it happens
Trigger: install_from_path(path) called with a directory, a dangling symlink, or a path that does not exist — typically a user-picked path passed through without normalization.
Common situations: User drags a folder instead of the .so/.dll/.dylib; path contains shell globs resolved wrongly; symlink to a lib that was moved; empty path from a cancelled file dialog.
Related errors
- pasta de origem não encontrada
- source not a file
- escolha a pasta de destino para organizar
- informe um appid, um link da loja ou marque a biblioteca…
- escolha a pasta da biblioteca de destino
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/887adee70d792ad3.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/onnxrt.rs:516
let canonical = make_canonical(&dir_for_task, &extracted)?;
let _ = std::fs::remove_file(&tmp_for_task);
Ok(canonical)
})
.await
.map_err(|e| anyhow!("tarefa de extração falhou: {e}"))??;
if let Some(marker) = version_marker_path() {
let _ = std::fs::write(&marker, format!("{} ({})", RUNTIME_VERSION, asset.file));
}
strip_quarantine(&out).await;
crate::core::tools::report(progress, "onnxruntime", "done", 1, Some(1), None);
Ok(out)
}
/// Instala a partir de um arquivo que o usuário já tem no disco.
pub fn install_from_path(source: &Path) -> anyhow::Result<PathBuf> {
if !source.is_file() {
return Err(anyhow!("{} não é um arquivo", source.display()));
}
let name = source
.file_name()
.and_then(|s| s.to_str())
.unwrap_or_default();
if !is_runtime_lib(name) {
return Err(anyhow!(
"{} não parece a biblioteca do ONNX Runtime deste sistema (esperava algo como {})",
name,
lib_filename()
));
}
let dir = target_dir().ok_or_else(|| anyhow!("não achei o diretório de dados do app"))?;
std::fs::create_dir_all(&dir).with_context(|| format!("criando {}", dir.display()))?;
let bytes = std::fs::read(source).with_context(|| format!("lendo {}", source.display()))?;
let dest = write_atomic(&dir, lib_filename(), &bytes)?;
if let Some(marker) = version_marker_path() {
let _ = std::fs::write(&marker, format!("local ({name})"));View on GitHub (pinned to 8600b91f42)