Skip to content

Poetry on Windows fails with File does not exists error #4479

Closed

Description

@lululukas
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10
  • Poetry version: 1.2.0a2
  • Link of a Gist with the contents of your pyproject.toml file: Will publish if necessary for this issue, don't think it is.

Issue

When trying to poetry add a dependency or do poetry install or poetry update, the command fails with an error saying that the file does not exist. The file refers to the weel of any dependencies that need to be installed. However, the file actually does exist at the correct location, but is somehow not found by poetry. I think this is due to a leading \ in the path. I haven't looked at the code, but I use bash bundled with git-for-windows in Windows Terminal. I assume that has something to do with the problem.

This is the error message, you can see the leading backslash in the path which I think is the culprit:

  ValueError

  File \C:\Users\<user>\AppData\Local\pypoetry\Cache\artifacts\ac\59\ac\9fc6b3c55594c6a7395665b20538ee05fb2ade328e723d2761b44c70ca\typed_ast-1.4.3-cp37-cp37m-win_amd64.whl does not exist

  at c:\users\<user>\appdata\roaming\pypoetry\venv\lib\site-packages\poetry\core\packages\file_dependency.py:41 in __init__
       37│             except FileNotFoundError:
       38│                 raise ValueError("Directory {} does not exist".format(self._path))
       39│
       40│         if not self._full_path.exists():
    →  41│             raise ValueError("File {} does not exist".format(self._path))
       42│
       43│         if self._full_path.is_dir():
       44│             raise ValueError("{} is a directory, expected a file".format(self._path))
       45│

However, the file does exist:

❯ file "C:\Users\<user>\AppData\Local\pypoetry\Cache\artifacts\ac\59\ac\9fc6b3c55594c6a7395665b20538ee05fb2ade328e723d2761b44c70ca\typed_ast-1.4.3-cp37-cp37m-win_amd64.whl"
C:\Users\<user>\AppData\Local\pypoetry\Cache\artifacts\ac\59\ac\9fc6b3c55594c6a7395665b20538ee05fb2ade328e723d2761b44c70ca\typed_ast-1.4.3-cp37-cp37m-win_amd64.whl: Zip archive data, at least v2.0 to extract, compression method=deflate

Edit:

I get the same error using powershell, so it seems like the issue is not related to using bash.

Activity

  1. added
    kind/bugSomething isn't working as expected
    status/triageThis issue needs to be triaged
    on Sep 6, 2021
  2. klnrdknt commented on Sep 20, 2021

    @klnrdknt

    As of today I have the exact same problem. (Havent updated any package in a while, so might have been there earlier).

    So far I've tried:

    • updating poetry
    • clearing the poetry cache
    • removing all virtual envs
    • reinstalling all packages
    • reinstalling poetry

    I am on the latest version of poetry.

  3. serverwentdown commented on Sep 21, 2021

    @serverwentdown
    Contributor

    The cause of the issue is in executor.py and core/packages/utils/link.py.

    Links (file:///C:/Users...) are converted into absolute paths (/C:/Users...) without accounting for Windows.

    This issue only surfaces when using the cached local packages.

  4. added 2 commits that reference this issue on Sep 21, 2021
    59e63d5
    7203328
  5. GoodiesHQ commented on Sep 22, 2021

    @GoodiesHQ

    I am experiencing this exact issue on Poetry 1.1.10. I am using pyenv to manage my python versions, currently using the most recent available, 3.9.7. Not sure how to proceed other than to use pip for now and remake dependencies once this has been solved. Thank you for your PR! Hopefully it will be done shortly.

  6. jonapich commented on Oct 6, 2021

    @jonapich
    Contributor

    For anyone who ran into this and bricked their installation, here's how to fix it:

    1. downgrade poetry to 1.1.9
    2. delete the cache folder MANUALLY (using poetry cache clear did not work, the leading \ still appeared afterwards.)

    You can locate your cache folder by calling poetry config --list.

  7. jonapich commented on Oct 13, 2021

    @jonapich
    Contributor

    Unfortunately the fix was temporary on my end. Still running into this regularly and have to wipe the cache each time.

  8. serverwentdown commented on Oct 13, 2021

    @serverwentdown
    Contributor

    @jonapich try applying my patches at #4549

  9. added a commit that references this issue on Oct 21, 2021
    84959aa
  10. added a commit that references this issue on Nov 12, 2021
    76e9560
  11. added a commit that references this issue on Nov 12, 2021
    315f9e4
  12. added a commit that references this issue on Nov 15, 2021
    feae2ab
  13. aptmess commented on Nov 15, 2021

    @aptmess

    For me this problem happens, when i tried to install package that was already installed and placed in Cache folder (for example, install dependencies for another project).

    Manually deleting folder Cache solves the problem on poetry version 1.11, but issue should be fixed in next version.

  14. dibog commented on Nov 16, 2021

    @dibog

    When will there be a fix for this?

  15. serverwentdown commented on Nov 16, 2021

    @serverwentdown
    Contributor

    @dibog Wait a while for the next release. In the meantime, you can install the branch with:

    (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python - --git https://github.com/python-poetry/poetry.git@1.1
    
  16. added a commit that references this issue on Nov 17, 2021
  17. lululukas commented on Dec 1, 2021

    @lululukas
    Author

    @dibog Wait a while for the next release. In the meantime, you can install the branch with:

    (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python - --git git+https://github.com/python-poetry/poetry.git@1.1
    

    Is this also available in the preview version (1.2.x) yet? I want to keep using that version, but I really need this patch.

  18. serverwentdown commented on Dec 2, 2021

    @serverwentdown
    Contributor

    @lululukas You can adjust the command accordingly, replace 1.1 with master

  19. lululukas commented on Dec 3, 2021

    @lululukas
    Author

    Failed with ERROR: Invalid requirement: 'git+git+https://github.com/python-poetry/poetry.git@master'.

    You have to remove the git+ so (Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python - --git https://github.com/python-poetry/poetry.git@master works.

    Thanks for the patch!

  20. mbardwell commented on Sep 15, 2023

    @mbardwell

    I experienced something similar on Windows 11 trying to install Sphinx. The problem was fixed by enabling long path lengths.

    My error

    ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\<me>\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\Local\\pypoetry\\Cache\\virtualenvs\\repo-zAvtZT_G-py3.11\\Lib\\site-packages\\sphinxcontrib\\serializinghtml\\locales\\ar\\LC_MESSAGES\\sphinxcontrib.serializinghtml.mo'
    HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
    

    https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell#enable-long-paths-in-windows-10-version-1607-and-later

  21. github-actions commented on Feb 29, 2024

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  22. locked as resolved and limited conversation to collaborators on Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions