diff --git a/cura/BackendPlugin.py b/cura/BackendPlugin.py index 5e885c3fd8a..0af40d89e9e 100644 --- a/cura/BackendPlugin.py +++ b/cura/BackendPlugin.py @@ -3,6 +3,7 @@ import socket import os import subprocess +import pathlib from typing import Optional, List from UM.Logger import Logger @@ -74,7 +75,8 @@ def start(self) -> bool: """ if not self.usePlugin(): return False - Logger.info(f"Starting backend_plugin [{self._plugin_id}] with command: {self._validatePluginCommand()}") + validated_plugin_command = self._validatePluginCommand() + Logger.info(f"Starting backend_plugin [{self._plugin_id}] with command: {validated_plugin_command}") plugin_log_path = os.path.join(Resources.getDataStoragePath(), f"{self.getPluginId()}.log") if os.path.exists(plugin_log_path): try: @@ -93,7 +95,14 @@ def start(self) -> bool: } if Platform.isWindows(): popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW - self._process = subprocess.Popen(self._validatePluginCommand(), **popen_kwargs) + + plugin_env = os.environ + if Platform.isLinux() and len(validated_plugin_command) > 0: + # Add plugin directory to AppImage "modules" directory so that it is started as if it was + # part of the AppImage and uses the sames libraries + plugin_env["APPDIR_MODULE_DIR"] = str(pathlib.Path(validated_plugin_command[0]).parent.absolute()) + + self._process = subprocess.Popen(validated_plugin_command, env=plugin_env, **popen_kwargs) self._is_running = True return True except PermissionError: