@@ -49,10 +49,23 @@ def __run_vboxmanage(cmd, real_time=False):
49
49
cmd: list with the command and its arguments
50
50
real_time: Boolean that determines if displaying the output in realtime or returning it.
51
51
"""
52
+ # When running as a PyInstaller bundle, LD_LIBRARY_PATH is set,
53
+ # which can cause conflicts with external binaries like VBoxManage.
54
+ # We create a clean environment for the subprocess to use the system's libraries.
55
+ env = os .environ .copy ()
56
+ if sys .frozen and "LD_LIBRARY_PATH" in env :
57
+ # 'sys.frozen' is True when running from a PyInstaller executable.
58
+ # We can either remove the variable or, more safely, restore the original
59
+ # one if PyInstaller saved it. PyInstaller often saves it as LD_LIBRARY_PATH_ORIG.
60
+ if "LD_LIBRARY_PATH_ORIG" in env :
61
+ env ["LD_LIBRARY_PATH" ] = env ["LD_LIBRARY_PATH_ORIG" ]
62
+ else :
63
+ del env ["LD_LIBRARY_PATH" ]
64
+
52
65
if real_time :
53
- return subprocess .run (cmd , stderr = sys .stderr , stdout = sys .stdout )
66
+ return subprocess .run (cmd , stderr = sys .stderr , stdout = sys .stdout , env = env )
54
67
else :
55
- return subprocess .run (cmd , text = True , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
68
+ return subprocess .run (cmd , text = True , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , env = env )
56
69
57
70
58
71
def run_vboxmanage (cmd , real_time = False ):
0 commit comments