Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temp files being deleted #4579

Closed
Dan203 opened this issue Dec 21, 2019 · 6 comments · Fixed by #4720
Closed

temp files being deleted #4579

Dan203 opened this issue Dec 21, 2019 · 6 comments · Fixed by #4720
Labels
area:bootloader Caused be or effecting the bootloader bug @high platform:Windows pull-request wanted Please submit a pull-request for this, maintainers will not actively work on this.

Comments

@Dan203
Copy link

Dan203 commented Dec 21, 2019

Reported this in #3301 but it still doesn't work the --runtime_tmpdir command nor the .spec option work for Windows builds. It still extracts to the regular system TEMP folder and if left running long enough the "unused" files get cleaned up by Windows (mostly icons and graphics files that are only loaded at startup) and then the program is all messed up.

In my case it's a tray app that's intended to run all the time, so after a week or so the tray icon gets messed up and the user has to restart the program for it to function properly again.

Any chance we could get the runtime_tmpdir functioning in Windows?

@Dan203
Copy link
Author

Dan203 commented Dec 26, 2019

A user just pointed out that this is in fact working, kind of. Instead of extracting to the folder I specified in the .spec file it's extractinging to the root of C:. So the flag is doing something, maybe my path syntax is just wrong? I'll have to play with it and see if can get it to work correctly.

@Dan203
Copy link
Author

Dan203 commented Dec 28, 2019

I couldn’t figure out any path format that worked for this. If I had any path in there at all it caused the temp files to be extracted to the root of C:, which is an issue for standard user accounts because they’re not allowed to write directly to the root, or if I remove it then it goes back to temp. I tried both the command line switch and a line in the .spec file with the same results.

Ultimately I reverted to using temp and dealing with the issues that causes. If anyone has a hint on how to make this work for a Windows app please let me know.

@htgoebel
Copy link
Member

The code is in pyi_utils.c:
pyi_create_temp_path() just takes the value of option pyi-runtime-tmpdir and passes it on to pyi_get_temp_path(). The later temporary changes %TMP% to the value of pyi-runtime-tmpdir.

Since the value is not toughed in any case, there might be some issues between characters and long characters. Do you have non-ascii in you path?

PS: Mind: PyInstaller is still in need of funding, see #4404

@htgoebel htgoebel added the area:bootloader Caused be or effecting the bootloader label Jan 17, 2020
@Dan203
Copy link
Author

Dan203 commented Jan 17, 2020

No. I tried hard coding just a simple path like c:\pyTivo, I tried using the appdata folder, I tried using the programdata folder. I tried with and without quotes. I tried with and without escaping the slashes. It either created them in the normal temp directory or created it right in the root of C. I was actually going to just leave it in the root of C as I thought that was better than files getting randomly getting deleted from the temp folder and causing issues, but then I started getting complaints that non-admin accounts aren’t allowed to just write to the root of C so the program would just fail.

This was for a Windows only build. I do have a Mac version of the app, but I wasn’t trying to update it yet.

@Legorooj Legorooj added solution:invalid solution:won't fix Resolved: Maintainers will not fix this. @high area:bootloader Caused be or effecting the bootloader bug pull-request wanted Please submit a pull-request for this, maintainers will not actively work on this. and removed area:bootloader Caused be or effecting the bootloader bug solution:invalid solution:won't fix Resolved: Maintainers will not fix this. labels Feb 26, 2020
@mcsimps2
Copy link
Contributor

mcsimps2 commented Mar 2, 2020

I'll also add to the conversation that I'm experiencing this bug - in my case, I'm actually getting cacert.pem deleted, which is causing TLS issues with the requests library. I can also vouch that, trying to use --runtime-tmpdir only moves the _MEI extraction folder to the root of the drive and not to the specified location.

@mcsimps2
Copy link
Contributor

mcsimps2 commented Mar 3, 2020

PR open. If you need to, checkout that branch; the following tests work:

  • pyinstaller --onefile --runtime-tmpdir ^%LOCALAPPDATA^%\MyNewApp app.py
  • pyinstaller --onefile --runtime-tmpdir C:\Users\ms\randomfolder app.py
  • pyinstaller --onefile --runtime-tmpdir . app.py (unpackages the app in the same directory where it exists)

app.py:

import sys
if __name__ == "__main__":
    print(f"The app is running in directory {sys._MEIPASS}")

mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Mar 10, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary.  As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths.  This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Mar 20, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary.  As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths.  This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Mar 21, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary.  As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths.  This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
@Legorooj Legorooj linked a pull request Apr 20, 2020 that will close this issue
mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Oct 27, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary.  As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths.  This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Oct 28, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary.  As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths.  This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Oct 29, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary.  As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths.  This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Oct 29, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary. As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths. This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
mcsimps2 added a commit to mcsimps2/pyinstaller that referenced this issue Oct 29, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary. As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths. This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
htgoebel pushed a commit to mcsimps2/pyinstaller that referenced this issue Dec 26, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary. As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths. This commit patches these bugs.

Resolves pyinstaller#4579 and pyinstaller#3301.
htgoebel pushed a commit that referenced this issue Dec 28, 2020
The --runtime-tmpdir option did not resolve environment variables, nor did
it create directories as necessary. As a result, the behavior usually
ended up placing the _MEIPASS folder in the root of the drive, especially
for non-existent paths. This commit patches these bugs.

Resolves #4579 and #3301.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:bootloader Caused be or effecting the bootloader bug @high platform:Windows pull-request wanted Please submit a pull-request for this, maintainers will not actively work on this.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants