I am using pyinstaller to create one file executable with command line. Like all "one file" exeutables, it extracts binaries/dependencies in one temporary folder of OS whenever opened. It generally clean those after closing the application properly but when I close the command line (or when the app crashes) then it leaves all those extracted temp files behind in that temp folder. And it creates new temp folder (with name "_Mxxxxxxx") every time I open the app, so the old crashed temp stays there if not cleaned manually.
I used the --runtime-tmpdir
parameter to specify one separate temp folder, but the same is happening there also. Any fix to this?
CodePudding user response:
This has been an issue with pyinstaller executables for some time, and doesn't really have a universally accepted solution. These are a few work arounds I have either used or seen:
One option would be to write code that doesn't crash. :)
Another is to include some code that cleans up any files from previous executions on program start
Another is to override the system except hook and force the app to exit gracefully, doesn't work in all situations
another is to specify the --runtime-tmpdir as you mentioned
another is to run the program in a docker container that can automatically perform cleanup itself.
As you can see most of them are kind of hacky and don't actually address the problem. Here is a link to the bug report on github. It has been an open issue since 2017 https://github.com/pyinstaller/pyinstaller/issues/2379