tonhowtf/omniget · error · anyhow::Error
source not a file
Error message
source not a file: {} What it means
set_pdfium_from_path() installs a pdfium shared library from a user-supplied path. Before doing anything it verifies the source path is an existing regular file; directories, symlinks to nothing, or nonexistent paths are rejected with this error that echoes the path via Display.
Solutions
- Pass the actual shared library file (e.g. libpdfium.so / pdfium.dll), not a directory or the archive
- Check the path exists with std::path::Path::is_file() before calling
- If starting from the downloaded archive, extract it first and locate pdfium_lib_filename() within
- Re-run ensure_pdfium() to get a valid library if the local copy is missing
Example fix
// before
set_pdfium_from_path(Path::new("~/Downloads/pdfium")).await?;
// after
let lib = Path::new("~/Downloads/pdfium/libpdfium.so");
if !lib.is_file() { panic!("select the library file, not the folder"); }
set_pdfium_from_path(lib).await?; Defensive patterns
Strategy: validation
Validate before calling
let p = std::path::Path::new(source);
if !p.is_file() {
eprintln!("{} is not a file — select the pdfium library itself", p.display());
} Type guard
fn is_regular_file(p: &std::path::Path) -> bool {
p.is_file() && std::fs::metadata(p).map(|m| m.len() > 0).unwrap_or(false)
} Try / catch
match set_pdfium_from_path(src) {
Err(e) if e.to_string().contains("source not a file") => {
// prompt user to pick the library file, not a directory/archive
}
other => other.map(|_| ()),
} Prevention
- In file pickers, filter to shared-library extensions (.so/.dll/.dylib)
- Resolve symlinks and expand ~ before passing paths
- Validate is_file() in the UI layer before calling the API
When it happens
Trigger: Calling set_pdfium_from_path() with a path that does not exist, points to a directory, or is a broken symlink — e.g. a typo'd path or passing the extracted archive directory instead of the .so/.dll inside it.
Common situations: User selects a folder instead of the library file in a picker; pointing at the downloaded .tar.gz instead of the extracted library; path moved after download.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- pasta de origem não encontrada
- não é um arquivo
- could not determine app data dir
- escolha a pasta de destino para organizar
- informe um appid, um link da loja ou marque a biblioteca…
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/5280baa527768719.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/pdfium.rs:229
{
let _ = tokio::task::spawn_blocking({
let p = target_path.clone();
move || {
crate::core::process::std_command("xattr")
.args(["-d", "com.apple.quarantine"])
.arg(&p)
.output()
}
})
.await;
}
Ok(target_path)
}
pub fn set_pdfium_from_path(source: &Path) -> anyhow::Result<PathBuf> {
if !source.is_file() {
return Err(anyhow!("source not a file: {}", source.display()));
}
let target_dir =
pdfium_target_dir().ok_or_else(|| anyhow!("could not determine app data dir"))?;
std::fs::create_dir_all(&target_dir)
.with_context(|| format!("creating pdfium target dir {}", target_dir.display()))?;
let lib_filename = pdfium_lib_filename();
let target_path = target_dir.join(lib_filename);
let tmp = target_dir.join(format!(".{}.tmp", lib_filename));
std::fs::copy(source, &tmp)
.with_context(|| format!("copying {} → {}", source.display(), tmp.display()))?;
if target_path.exists() {
let _ = std::fs::remove_file(&target_path);
}
std::fs::rename(&tmp, &target_path)
.with_context(|| format!("renaming temp to {}", target_path.display()))?;
if let Some(version_marker) = pdfium_version_marker_path() {View on GitHub (pinned to 8600b91f42)