Skip to content

Commit

Permalink
fix: get correct resource dir in AppImge (fix #1308) (#1333)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
gabcoh and lucasfernog committed Mar 13, 2021
1 parent 2db901e commit bd1df5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-resource-dir-app-image.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Fixes `resource_dir` resolution on AppImage.
15 changes: 12 additions & 3 deletions tauri-utils/src/platform.rs
@@ -1,4 +1,7 @@
use std::path::{PathBuf, MAIN_SEPARATOR};
use std::{
env,
path::{PathBuf, MAIN_SEPARATOR},
};

/// Try to determine the current target triple.
///
Expand Down Expand Up @@ -55,8 +58,12 @@ pub fn target_triple() -> crate::Result<String> {
///
/// On Windows, it's the path to the executable.
///
/// On Linux, it's `/usr/lib/${exe_name}` when running the bundled app,
/// and `${exe_dir}/../lib/${exe_name}` when running the app from `src-tauri/target/(debug|release)/`.
/// On Linux, when running in an AppImage the `APPDIR` variable will be set to
/// the mounted location of the app, and the resource dir will be
/// `${APPDIR}/usr/lib/${exe_name}`. If not running in an AppImage, the path is
/// `/usr/lib/${exe_name}`. When running the app from
/// `src-tauri/target/(debug|release)/`, the path is
/// `${exe_dir}/../lib/${exe_name}`.
///
/// On MacOS, it's `${exe_dir}../Resources` (inside .app).
pub fn resource_dir() -> crate::Result<PathBuf> {
Expand All @@ -80,6 +87,8 @@ pub fn resource_dir() -> crate::Result<PathBuf> {
if curr_dir.ends_with("/data/usr/bin") {
// running from the deb bundle dir
Ok(exe_dir.join(format!("../lib/{}", app_name)))
} else if let Ok(appdir) = env::var("APPDIR") {
Ok(PathBuf::from(format!("{}/usr/lib/{}", appdir, app_name)))
} else {
// running bundle
Ok(PathBuf::from(format!("/usr/lib/{}", app_name)))
Expand Down

0 comments on commit bd1df5d

Please sign in to comment.