diff --git a/.changes/enhance-resource-dir-linux.md b/.changes/enhance-resource-dir-linux.md new file mode 100644 index 000000000000..c528bad12467 --- /dev/null +++ b/.changes/enhance-resource-dir-linux.md @@ -0,0 +1,5 @@ +--- +"tauri-utils": patch:bug +--- + +Enhance resource directory resolution to support running on distros like NixOS. diff --git a/crates/tauri-cli/src/mobile/init.rs b/crates/tauri-cli/src/mobile/init.rs index 4c2a29e34f6a..c24ddbe84408 100644 --- a/crates/tauri-cli/src/mobile/init.rs +++ b/crates/tauri-cli/src/mobile/init.rs @@ -198,17 +198,9 @@ fn get_str<'a>(helper: &'a Helper) -> &'a str { fn get_str_array(helper: &Helper, formatter: impl Fn(&str) -> String) -> Option> { helper.param(0).and_then(|v| { - v.value().as_array().and_then(|arr| { - arr - .iter() - .map(|val| { - val.as_str().map( - #[allow(clippy::redundant_closure)] - |s| formatter(s), - ) - }) - .collect() - }) + v.value() + .as_array() + .and_then(|arr| arr.iter().map(|val| val.as_str().map(&formatter)).collect()) }) } diff --git a/crates/tauri-utils/src/platform.rs b/crates/tauri-utils/src/platform.rs index 162539c9692b..7a9c99431ed5 100644 --- a/crates/tauri-utils/src/platform.rs +++ b/crates/tauri-utils/src/platform.rs @@ -309,12 +309,12 @@ fn resource_dir_from>( #[cfg(target_os = "linux")] { - res = if curr_dir.ends_with("/data/usr/bin") { - // running from the deb bundle dir - exe_dir - .join(format!("../lib/{}", package_info.name)) - .canonicalize() - .map_err(Into::into) + // (canonicalize checks for existence, so there's no need for an extra check) + res = if let Ok(bundle_dir) = exe_dir + .join(format!("../lib/{}", package_info.name)) + .canonicalize() + { + Ok(bundle_dir) } else if let Some(appdir) = &env.appdir { let appdir: &std::path::Path = appdir.as_ref(); Ok(PathBuf::from(format!(