flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.39k stars 445 forks source link

Directory not empty and permission errors when running builds on Windows. #2465

Open EasyDevv opened 9 months ago

EasyDevv commented 9 months ago

Description

flet build windows

I ran a build as administrator in cmd and got a permission error and a directory not empty error

I have disabled Storage Sense because I suspect the temp folder is being used, but there is no change.

Code example to reproduce the issue:

Creating Flutter bootstrap project...OK
Customizing app icons and splash images...OK
Generating app icons...OK
Packaging Python app...Running package command
Creating asset directory: C:\Users\me\AppData\Local\Temp\flet_flutter_build_pIMgoDqlnE\app
Copying Python app from C:\Projects\Works\ImageManager to C:\Users\me\AppData\Local\Temp\serious_python_tempae29ade6
Installing dependencies  with pip command to
C:\Users\me\AppData\Local\Temp\serious_python_tempae29ade6\__pypackages__
Extracting Python distributive from
C:\Users\me\AppData\Local\Temp\cpython-3.11.6+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz to
C:\Users\me\AppData\Local\Temp\hostpython3.11_1f0b3c4f
Compiling Python sources at C:\Users\me\AppData\Local\Temp\serious_python_tempae29ade6
Error: FormatException: Unexpected extension byte (at offset 5915)
Deleting temp directory C:\Users\me\AppData\Local\Temp\serious_python_tempae29ade6

Unhandled exception:
FileSystemException: Deletion failed, path = 'C:\Users\me\AppData\Local\Temp\serious_python_tempae29ade6' (OS Error:
The directory is not empty.
, errno = 145)
#0      _checkForErrorResponse (dart:io/common.dart:55:9)
#1      _Directory._delete.<anonymous closure> (dart:io/directory_impl.dart:185:7)
<asynchronous suspension>
#2      PackageCommand.run
(file:///C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/serious_python-0.7.0/bin/package_command.dart:354:9)
<asynchronous suspension>
#3      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#4      main (file:///C:/Users/me/AppData/Local/Pub/Cache/hosted/pub.dev/serious_python-0.7.0/bin/main.dart:10:3)
<asynchronous suspension>

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Scripts\flet.exe\__main__.py", line 7, in <module>
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\site-packages\flet\cli\cli.py", line 83, in main
    args.handler(args)
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\site-packages\flet\cli\commands\build.py", line 602, in handle
    self.cleanup(package_result.returncode)
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\site-packages\flet\cli\commands\build.py", line 748, in cleanup
    shutil.rmtree(str(self.flutter_dir), ignore_errors=False, onerror=None)
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\shutil.py", line 759, in rmtree
    return _rmtree_unsafe(path, onerror)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\shutil.py", line 626, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\shutil.py", line 624, in _rmtree_unsafe
    os.rmdir(path)
PermissionError: [WinError 32] The process cannot access the file because another process is using it: 'C:\\Users\\me\\AppData\\Local\\Temp\\flet_flutter_build_pIMgoDqlnE'

Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Flet version (pip show flet):

0.19.0

Operating system: Windows 11

Additional environment details:

david-shu commented 9 months ago

I encountered a similar error when i run " flet build web -vv" and " flet build windows -vv"

Error: FormatException: Unexpected extension byte (at offset 6212)

hugopy commented 8 months ago

I too encountered a similar error and still haven't figured out a solution.