{"record":{"id":"6a59080625f08273","repo":"tauri-apps/tauri","slug":"couldn-t-get-library-filename","errorCode":null,"errorMessage":"Couldn't get library filename","messagePattern":"Couldn't get library filename","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/tauri-build/src/lib.rs","lineNumber":186,"sourceCode":"// Copies the macOS application bundle frameworks to the target folder\nfn copy_frameworks(dest_dir: &Path, frameworks: &[String]) -> Result<()> {\n  fs::create_dir_all(dest_dir)\n    .with_context(|| format!(\"Failed to create frameworks output directory at {dest_dir:?}\"))?;\n  for framework in frameworks.iter() {\n    if framework.ends_with(\".framework\") {\n      let src_path = Path::new(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      copy_dir(src_path, &dest_path)?;\n      continue;\n    } else if framework.ends_with(\".dylib\") {\n      let src_path = Path::new(framework);\n      if !src_path.exists() {\n        return Err(anyhow::anyhow!(\"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      copy_file(src_path, &dest_path)?;\n      continue;\n    } else if framework.contains('/') {\n      return Err(anyhow::anyhow!(\n        \"Framework path should have .framework extension: {}\",\n        framework\n      ));\n    }\n    if let Some(home_dir) = dirs::home_dir() {\n      if copy_framework_from(&home_dir.join(\"Library/Frameworks/\"), framework, dest_dir)? {\n        continue;\n      }\n    }\n    if copy_framework_from(\"/Library/Frameworks/\".as_ref(), framework, dest_dir)?\n      || copy_framework_from(\"/Network/Library/Frameworks/\".as_ref(), framework, dest_dir)?\n    {\n      continue;","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-build/src/lib.rs#L168-L204","documentation":"In tauri-build's copy_frameworks, a `.dylib` entry that exists on disk is copied by joining its `file_name()` to the destination directory. If the dylib path lacks a final component (root, trailing separator, `..`), file_name() returns None and the expect panics. Since existence was already checked, this only happens for structurally malformed paths that nonetheless resolve oddly (or races replaced the path).","triggerScenarios":"tauri_build::try_build with Attributes::copy_frameworks containing a `.dylib` path such as `/path/to/..` or ending in `/` that still passes the `exists()` check but yields no filename.","commonSituations":"Paths assembled from environment variables where the dylib name was dropped; using a directory that happens to end in `.dylib` is impossible but a symlink or `..`-based path can slip through the exists() check.","solutions":["Ensure the dylib entry in tauri.conf.json ends with the actual file name, e.g. `libs/libfoo.dylib`.","Strip `..` and trailing separators; use a canonical absolute path.","Check that the file (not a directory) exists at that exact path.","Fail fast in your build script: `assert!(p.is_file() && p.file_name().is_some())` before try_build."],"exampleFix":"// before\n\"frameworks\": [\"/usr/local/lib/\"]\n// after\n\"frameworks\": [\"/usr/local/lib/libmylib.dylib\"]","handlingStrategy":"validation","validationCode":"let p = std::path::Path::new(\"libs/libmylib.dylib\");\nassert!(p.is_file() && p.file_name().is_some(), \"dylib path invalid: {}\", p.display());","typeGuard":"fn valid_dylib(p: &std::path::Path) -> bool {\n  p.file_name().is_some() && p.is_file() && p.extension().map_or(false, |e| e == \"dylib\")\n}","tryCatchPattern":null,"preventionTips":["Check with is_file(), not exists(), so directories and dangling links are rejected.","Canonicalize generated paths before placing them in tauri.conf.json.","Keep dylib entries generated by a single, tested script."],"tags":["build","macos","dylib","path","panic"],"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"}