Skip to content

Commit bd1df5d

Browse files
gabcohlucasfernog
andauthored
fix: get correct resource dir in AppImge (fix #1308) (#1333)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent 2db901e commit bd1df5d

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Fixes `resource_dir` resolution on AppImage.

tauri-utils/src/platform.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::path::{PathBuf, MAIN_SEPARATOR};
1+
use std::{
2+
env,
3+
path::{PathBuf, MAIN_SEPARATOR},
4+
};
25

36
/// Try to determine the current target triple.
47
///
@@ -55,8 +58,12 @@ pub fn target_triple() -> crate::Result<String> {
5558
///
5659
/// On Windows, it's the path to the executable.
5760
///
58-
/// On Linux, it's `/usr/lib/${exe_name}` when running the bundled app,
59-
/// and `${exe_dir}/../lib/${exe_name}` when running the app from `src-tauri/target/(debug|release)/`.
61+
/// On Linux, when running in an AppImage the `APPDIR` variable will be set to
62+
/// the mounted location of the app, and the resource dir will be
63+
/// `${APPDIR}/usr/lib/${exe_name}`. If not running in an AppImage, the path is
64+
/// `/usr/lib/${exe_name}`. When running the app from
65+
/// `src-tauri/target/(debug|release)/`, the path is
66+
/// `${exe_dir}/../lib/${exe_name}`.
6067
///
6168
/// On MacOS, it's `${exe_dir}../Resources` (inside .app).
6269
pub fn resource_dir() -> crate::Result<PathBuf> {
@@ -80,6 +87,8 @@ pub fn resource_dir() -> crate::Result<PathBuf> {
8087
if curr_dir.ends_with("/data/usr/bin") {
8188
// running from the deb bundle dir
8289
Ok(exe_dir.join(format!("../lib/{}", app_name)))
90+
} else if let Ok(appdir) = env::var("APPDIR") {
91+
Ok(PathBuf::from(format!("{}/usr/lib/{}", appdir, app_name)))
8392
} else {
8493
// running bundle
8594
Ok(PathBuf::from(format!("/usr/lib/{}", app_name)))

0 commit comments

Comments
 (0)