diff --git a/src/main/server.c b/src/main/server.c index 52018a0acd1dde563516d209998a415fd94d3fd8..f04a318e305743185a334c6fe25cbf000219aafe 100644 --- a/src/main/server.c +++ b/src/main/server.c @@ -217,6 +217,8 @@ end: return 0; } +static int ___is_appimage = 0; + static inline void ___resolve_appimage(void) { @@ -232,6 +234,7 @@ ___resolve_appimage(void) LOG_DEBUG("INIT", "AppImage env APPDIR = %s", env_APPDIR); LOG_DEBUG("INIT", "AppImage env OWD = %s", env_OWD); LOG_DEBUG("INIT", "AppImage env ARGV0 = %s", env_ARGV0); + ___is_appimage = 1; } else LOG_DEBUG("INIT", "No AppImage env variable found!"); } @@ -240,6 +243,15 @@ static inline void ___resolve_path(void) { const char *env_PATH = getenv("PATH"); + if (___is_appimage) { + char new_path[PATH_MAX]; + char exe_path[LKT_LINE_MAX]; + GOTO_IF(read_self_exe(exe_path, LKT_LINE_MAX), "Failed to get exe path", error); + char *self_dir = dirname(exe_path); + safe_snprintf(new_path, PATH_MAX, "%s:%s", self_dir, env_PATH); + GOTO_IF(setenv("PATH", new_path, 1), "Failed to set new PATH", error); + } +error: LOG_DEBUG("INIT", "PATH is: %s", env_PATH); }