fix: restore environment before launching external programs #707
+31
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
By default, any subprocesses will inherit environment variables from its parent. Pyinstaller will specify a custom
LD_LIBRARY_PATH
, which causes issues when the subprocess attempts to load its own dynamically linked libraries.https://web.archive.org/web/20240824170055/https://github.com/TagStudioDev/TagStudio/issues/210
Solution
Implemented suggested solutions for linux and windows from https://pyinstaller.org/en/stable/common-issues-and-pitfalls.html#launching-external-programs-from-the-frozen-application. Doesn't really seem like a solution for MacOS is necessary based on the docs.
Renamed and slightly reworked promptless_Popen into silent_Popen (better name, and congruent with the actual file name) so future features can take advantage of the same solution.
Tested on linux and briefly on windows (but could not figure out a way of getting hold of an outdated dll). At least it shouldn't be worse.