From ec567f686709fe07cd80bd456e78d40a0ec5f16f Mon Sep 17 00:00:00 2001 From: Sandip Date: Mon, 17 Jan 2022 17:31:44 +0100 Subject: [PATCH] Skip first sys.argv on frozen environment --- src/tribler-gui/tribler_gui/core_manager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tribler-gui/tribler_gui/core_manager.py b/src/tribler-gui/tribler_gui/core_manager.py index 18cf95bfc37..daea50af2ab 100644 --- a/src/tribler-gui/tribler_gui/core_manager.py +++ b/src/tribler-gui/tribler_gui/core_manager.py @@ -92,7 +92,11 @@ def start_tribler_core(self): core_args = self.core_args if not core_args: - core_args = sys.argv + ['--core'] + # If the core is running on frozen environment, sys.argv[0] becomes tribler executable while + # running from source code, sys.argv[0] is run_tribler.py which is run by python runtime. + # So, we skip the first argument to prevent argument parsing error on frozen environment. + sys_argv = sys.argv if not hasattr(sys, '_MEIPASS') else sys.argv[1:] if len(sys.argv) > 1 else [] + core_args = sys_argv + ['--core'] self.core_process = QProcess() self.core_process.setProcessEnvironment(core_env)