tauri-apps/tauri · error
Couldn't get library filename
Error message
Couldn't get library filename
What it means
In the macOS bundler's copy_frameworks_to_bundle, `.dylib` entries that pass an existence check are copied via `file_name()`. If the dylib path has no final component, file_name() returns None and the expect panics. As in the build-side twin, a path that exists but has no filename (root, `..`, trailing-separator oddity) reaches this point only if malformed.
Solutions
- Ensure each dylib entry ends with the file name, e.g. `libs/libfoo.dylib`.
- Canonicalize the path to remove `..` and trailing separators before configuring.
- Verify `is_file()` (not just `exists()`) at the configured path.
- Add a pre-build assertion for filename presence in any script that generates the frameworks list.
Example fix
// before "frameworks": ["target/debug/"] // after "frameworks": ["target/debug/libmylib.dylib"]
Defensive patterns
Strategy: validation
Validate before calling
let p = std::path::PathBuf::from("libs/libmylib.dylib");
assert!(p.is_file() && p.file_name().is_some(), "invalid dylib for macOS bundle: {}", p.display()); Type guard
fn valid_dylib(p: &std::path::Path) -> bool { p.file_name().is_some() && p.is_file() } Prevention
- Use canonical absolute paths for dylibs in the frameworks list.
- Verify with is_file() during a pre-bundle validation step.
- Avoid constructing dylib paths via string concatenation; use PathBuf::join.
When it happens
Trigger: tauri build creating a macOS .app with a `.dylib` framework entry whose path (e.g. `/usr/lib/..` or ending in `/`) exists but yields no file name for the destination join.
Common situations: Dylib paths assembled from concatenation where the filename was dropped; pointing at a directory whose name coincidentally passes checks; symlinked paths rewritten to parent directories.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Couldn't get framework filename
- Couldn't get library filename
- Couldn't get framework filename
- No file name
- Path has no file_name
AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18).
Data as JSON: /api/errors/ff513d64442701a5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tauri-bundler/src/bundle/macos/app.rs:411
}
let dest_dir = bundle_directory.join("Frameworks");
fs::create_dir_all(&dest_dir).fs_context("failed to create Frameworks directory", &dest_dir)?;
for framework in frameworks.iter() {
if framework.ends_with(".framework") {
let src_path = PathBuf::from(framework);
let src_name = src_path
.file_name()
.expect("Couldn't get framework filename");
let dest_path = dest_dir.join(src_name);
fs_utils::copy_dir(&src_path, &dest_path)?;
add_framework_sign_path(&src_path, &dest_path, &mut paths);
continue;
} else if framework.ends_with(".dylib") {
let src_path = PathBuf::from(framework);
if !src_path.exists() {
return Err(GenericError(format!("Library not found: {framework}")));
}
let src_name = src_path.file_name().expect("Couldn't get library filename");
let dest_path = dest_dir.join(src_name);
fs_utils::copy_file(&src_path, &dest_path)?;
paths.push(SignTarget {
path: dest_path,
is_an_executable: false,
});
continue;
} else if framework.contains('/') {
return Err(GenericError(format!(
"Framework path should have .framework extension: {framework}"
)));
}
if let Some(home_dir) = dirs::home_dir() {
if copy_framework_from(&dest_dir, framework, &home_dir.join("Library/Frameworks/"))? {
continue;
}
}
if copy_framework_from(&dest_dir, framework, &PathBuf::from("/Library/Frameworks/"))?View on GitHub (pinned to 460ec35447)