FileNotFoundError: [Errno 2] No such file or directory
Describe the bug
Hi, When I try to use the command "pdm update".
I received a error :
FileNotFoundError: [Errno 2] No such file or directory: ~\\AppData\\Local\\pdm\\pdm\\Cache\\wheels\\........
And I try to use the "pdm chache clear" to fix it, and it didn't work.
And I found, there is no dictionary named "pdm" under "Local".
To reproduce
pdm update
Expected Behavior
use "pdm update"
Environment Information
PDM version:
2.21.0
Python Interpreter:
****\python.exe (3.10)
Project Root:
****
Local Packages:
(empty)
{
"implementation_name": "cpython",
"implementation_version": "3.12.8",
"os_name": "nt",
"platform_machine": "AMD64",
"platform_release": "11",
"platform_system": "Windows",
"platform_version": "10.0.26100",
"python_full_version": "3.10.11",
"platform_python_implementation": "CPython",
"python_version": "3.10",
"sys_platform": "win32"
}
Verbose Command Output
✖ Update *** 1.6.0 -> 1.6.0 failed
pdm.termui: Error occurs updating ***:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\synchronizers.py", line 50, in update_candidate
self.manager.overwrite(dist, can)
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 62, in overwrite
installed = self.install(candidate)
^^^^^^^^^^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 32, in install
dist_info = install_wheel(
^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\installers.py", line 193, in install_wheel
with WheelFile.open(wheel) as source:
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\installer\sources.py", line 162, in open
with zipfile.ZipFile(path) as f:
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\zipfile\__init__.py", line 1331, in __init__
self.fp = io.open(file, filemode)
^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '~\\AppData\\Local\\pdm\\pdm\\Cache\\wheels\\83\\b5\\d1\\*******.whl'
Retry failed jobs(2/2)
pdm.termui: Overwriting distribution ***
✖ Update *** 1.6.0 -> 1.6.0 failed
pdm.termui: Error occurs updating ***:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\synchronizers.py", line 50, in update_candidate
self.manager.overwrite(dist, can)
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 62, in overwrite
installed = self.install(candidate)
^^^^^^^^^^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\manager.py", line 32, in install
dist_info = install_wheel(
^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\installers.py", line 193, in install_wheel
with WheelFile.open(wheel) as source:
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\installer\sources.py", line 162, in open
with zipfile.ZipFile(path) as f:
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\zipfile\__init__.py", line 1331, in __init__
self.fp = io.open(file, filemode)
^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '~\\AppData\\Local\\pdm\\pdm\\Cache\\wheels\\83\\b5\\d1\\******.whl'
✖ Some package operations failed.
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "~\.local\bin\pdm.exe\__main__.py", line 7, in <module>
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 392, in main
return core.main(args or sys.argv[1:])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 270, in main
raise cast(Exception, err).with_traceback(traceback) from None
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 265, in main
self.handle(project, options)
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 195, in handle
command.handle(project, options)
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\update.py", line 75, in handle
self.do_update(
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\update.py", line 200, in do_update
do_sync(
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\cli\actions.py", line 301, in do_sync
synchronizer.synchronize()
File "~\pipx\venvs\pdm\Lib\site-packages\pdm\installers\synchronizers.py", line 226, in synchronize
raise InstallationError("Some package operations failed.")
pdm.exceptions.InstallationError: Some package operations failed.
Additional Context
No response
Are you willing to submit a PR to fix this bug?
- [X] Yes, I would like to submit a PR.
I don't know how to reproduce it because I can't (on MacOS)
I don't know how to reproduce it because I can't (on MacOS)
It seems that PDM uses some mechanism to cache downloaded packages. From the error message, it can be seen that PDM tried to use the cached package, but did not find it in the corresponding location. This may be due to some reasons, such as version update causing caching. The folder has changed, for example I accidentally deleted the cache folder.
So one of the solutions I can think of, is to clear the cached mapping of the pdm record. But no matter if I try to reinstall pdm or something else, I can't do it to refresh the record. (I use PIPX). If I could know, Where does PDM read cache records and clear it, maybe the problem will be solved
is to clear the cached mapping of the pdm record
There is no such mapping, we just map the cache key to the file path under cache folder
Does the path look right? double pdm? I do not own a Windows machine so cannot verify.
~\AppData\Local\pdm\pdm\Cache\wheels\
On linux this is just ~/.cache/pdm/...
$ ls -l ~/.cache/pdm/
total 4
drwxr-xr-x. 1 klmcw klmcw 896 Dec 30 19:23 hashes
drwxr-xr-x. 1 klmcw klmcw 31700 Jan 2 21:39 http
drwxr-xr-x. 1 klmcw klmcw 580 Jan 2 17:21 metadata
drwxr-xr-x. 1 klmcw klmcw 112 Dec 28 05:31 self-check
-rw-r--r--. 1 klmcw klmcw 205 Dec 30 13:09 use_cache.json
drwxr-xr-x. 1 klmcw klmcw 16 Dec 30 19:23 wheels