{"record":{"id":"ff513d64442701a5","repo":"tauri-apps/tauri","slug":"couldn-t-get-library-filename-app","errorCode":null,"errorMessage":"Couldn't get library filename","messagePattern":"Couldn't get library filename","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/bundle/macos/app.rs","lineNumber":411,"sourceCode":"  }\n  let dest_dir = bundle_directory.join(\"Frameworks\");\n  fs::create_dir_all(&dest_dir).fs_context(\"failed to create Frameworks directory\", &dest_dir)?;\n  for framework in frameworks.iter() {\n    if framework.ends_with(\".framework\") {\n      let src_path = PathBuf::from(framework);\n      let src_name = src_path\n        .file_name()\n        .expect(\"Couldn't get framework filename\");\n      let dest_path = dest_dir.join(src_name);\n      fs_utils::copy_dir(&src_path, &dest_path)?;\n      add_framework_sign_path(&src_path, &dest_path, &mut paths);\n      continue;\n    } else if framework.ends_with(\".dylib\") {\n      let src_path = PathBuf::from(framework);\n      if !src_path.exists() {\n        return Err(GenericError(format!(\"Library not found: {framework}\")));\n      }\n      let src_name = src_path.file_name().expect(\"Couldn't get library filename\");\n      let dest_path = dest_dir.join(src_name);\n      fs_utils::copy_file(&src_path, &dest_path)?;\n      paths.push(SignTarget {\n        path: dest_path,\n        is_an_executable: false,\n      });\n      continue;\n    } else if framework.contains('/') {\n      return Err(GenericError(format!(\n        \"Framework path should have .framework extension: {framework}\"\n      )));\n    }\n    if let Some(home_dir) = dirs::home_dir() {\n      if copy_framework_from(&dest_dir, framework, &home_dir.join(\"Library/Frameworks/\"))? {\n        continue;\n      }\n    }\n    if copy_framework_from(&dest_dir, framework, &PathBuf::from(\"/Library/Frameworks/\"))?","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-bundler/src/bundle/macos/app.rs#L393-L429","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n\"frameworks\": [\"target/debug/\"]\n// after\n\"frameworks\": [\"target/debug/libmylib.dylib\"]","handlingStrategy":"validation","validationCode":"let p = std::path::PathBuf::from(\"libs/libmylib.dylib\");\nassert!(p.is_file() && p.file_name().is_some(), \"invalid dylib for macOS bundle: {}\", p.display());","typeGuard":"fn valid_dylib(p: &std::path::Path) -> bool { p.file_name().is_some() && p.is_file() }","tryCatchPattern":null,"preventionTips":["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."],"tags":["macos","dylib","path","panic","bundling"],"backgroundTag":"invalid-argument-format","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}