{"record":{"id":"649bf62c606f7379","repo":"tauri-apps/tauri","slug":"couldn-t-get-parent-of-target-path","errorCode":null,"errorMessage":"Couldn't get parent of target path","messagePattern":"Couldn't get parent of target path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-bundler/src/bundle/windows/nsis/mod.rs","lineNumber":848,"sourceCode":"    // In some glob resource paths like `assets/**/*` a file might appear twice\n    // because the `tauri_utils::resources::ResourcePaths` iterator also reads a directory\n    // when it finds one. So we must check it before processing the file.\n    if added_resources.contains(&resource_path) {\n      continue;\n    }\n    added_resources.push(resource_path.clone());\n\n    if settings.windows().can_sign() && should_sign(&resource_path)? {\n      try_sign(&resource_path, settings)?;\n    }\n\n    let target_path = resource.target();\n    resources.insert(\n      resource_path,\n      (\n        target_path\n          .parent()\n          .expect(\"Couldn't get parent of target path\")\n          .to_path_buf(),\n        target_path.to_path_buf(),\n      ),\n    );\n  }\n\n  Ok(resources)\n}\n\n/// BTreeMap<OriginalPath, TargetFileName>\ntype BinariesMap = BTreeMap<PathBuf, String>;\nfn generate_binaries_data(settings: &Settings) -> crate::Result<BinariesMap> {\n  let mut binaries = BinariesMap::new();\n  let cwd = std::env::current_dir()?;\n\n  for src in settings.external_binaries() {\n    let src = src?;\n    let binary_path = dunce::canonicalize(cwd.join(&src))?;","sourceCodeStart":830,"sourceCodeEnd":866,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs#L830-L866","documentation":"In generate_resource_data, each bundled resource's target path inside the installer is split into a parent directory and file name via Path::parent().expect(). If the resource target path has no parent (a bare relative file name like 'foo.txt' with no directory component), the panic \"Couldn't get parent of target path\" is raised.","triggerScenarios":"build_nsis_app_installer -> generate_resource_data when a resource listed in tauri.conf.json maps to a target path that is a bare filename with no directory prefix (Path::parent() returns Some only when there is a directory component).","commonSituations":"Resources map in tauri.conf.json written as {\"resources\": [\"file.txt\"]} combined with target rewriting, or a map entry whose destination is just a filename instead of a destination directory; typos producing a single-component path.","solutions":["Give the resource destination a directory component, e.g. map to 'data/file.txt' instead of 'file.txt'.","Check the resources config in tauri.conf.json for entries that resolve to bare filenames and add the intended destination directory.","Ensure custom target-path rewriting (if any plugin/code modifies targets) always produces a path with a parent."],"exampleFix":"// before (tauri.conf.json)\n\"resources\": {\"./legal.txt\": \"legal.txt\"}\n// after\n\"resources\": {\"./legal.txt\": \"docs/legal.txt\"}","handlingStrategy":"validation","validationCode":"// Validate resources config before building: every destination must have a directory component\nuse std::path::Path;\nfn dest_ok(dest: &str) -> bool {\n  Path::new(dest).parent().map(|p| !p.as_os_str().is_empty()).unwrap_or(false)\n}\n// assert every mapped destination passes dest_ok()","typeGuard":"fn has_parent(p: &std::path::Path) -> bool {\n  p.parent().map(|parent| !parent.as_os_str().is_empty()).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Always give resource destinations a directory prefix in tauri.conf.json.","Review resources mappings after config refactors.","Test `tauri build` for each target OS in CI to catch path-shape issues early."],"tags":["windows","nsis","resources","path","bundler"],"backgroundTag":"invalid-argument-value","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"}