Fix asset location for linux bundles (#4460)

* fix linux bundle

* fix release mode

* fix resource path

* only use asset dir if it exists

* add comment about directory structure

* don't unwrap parent
This commit is contained in:
Evan Almloff authored and GitHub committed 2025-07-23 17:47:41 -07:00
1 parent 66c2dac38f
commit 15d369f10f
3 files changed
+28 -2

No files matched your search

+20 -1
View File
@@ -80,7 +80,7 @@ pub fn serve_asset(path: &str) -> Result<Response<Vec<u8>>, AssetServeError> {
/// - [x] Windows
/// - [x] Linux (appimage)
/// - [ ] Linux (rpm)
/// - [ ] Linux (deb)
/// - [x] Linux (deb)
/// - [ ] Android
#[allow(unreachable_code)]
fn get_asset_root() -> PathBuf {
@@ -96,6 +96,25 @@ fn get_asset_root() -> PathBuf {
.join("Resources");
}
#[cfg(target_os = "linux")]
{
// In linux bundles, the assets are placed in the lib/$product_name directory
// bin/
// main
// lib/
// $product_name/
// assets/
if let Some(product_name) = dioxus_cli_config::product_name() {
let lib_asset_path = || {
let path = cur_exe.parent()?.parent()?.join("lib").join(product_name);
path.exists().then_some(path)
};
if let Some(asset_dir) = lib_asset_path() {
return asset_dir;
}
}
}
// For all others, the structure looks like this:
// app.(exe/appimage)
// main.exe