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

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

Closed
3 tasks done
lululukas opened this issue Sep 6, 2021 · 14 comments · Fixed by #4531
Closed
3 tasks done

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

lululukas opened this issue Sep 6, 2021 · 14 comments · Fixed by #4531
Labels
kind/bug Something isn't working as expected

Comments

@lululukas
Copy link

lululukas commented Sep 6, 2021

  • 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.

@lululukas lululukas added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 6, 2021
@klnrdknt
Copy link

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.

@serverwentdown
Copy link
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.

serverwentdown added a commit to serverwentdown/poetry that referenced this issue Sep 21, 2021
Closes python-poetry#4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use the utility function url_to_path.
serverwentdown added a commit to serverwentdown/poetry that referenced this issue Sep 21, 2021
Closes python-poetry#4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use the utility function url_to_path.
@GoodiesHQ
Copy link

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.

@jonapich
Copy link
Contributor

jonapich commented Oct 6, 2021

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.

@jonapich
Copy link
Contributor

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

@serverwentdown
Copy link
Contributor

@jonapich try applying my patches at #4549

serverwentdown added a commit to serverwentdown/poetry that referenced this issue Oct 21, 2021
Closes python-poetry#4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use the utility function url_to_path.
serverwentdown added a commit to serverwentdown/poetry that referenced this issue Nov 12, 2021
Closes python-poetry#4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use the utility function url_to_path.
neersighted pushed a commit that referenced this issue Nov 12, 2021
Closes #4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use `Link` and `url_to_path`.
1nF0rmed pushed a commit to 1nF0rmed/poetry that referenced this issue Nov 15, 2021
Closes python-poetry#4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use `Link` and `url_to_path`.
@aptmess
Copy link

aptmess commented Nov 15, 2021

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.

@dibog
Copy link

dibog commented Nov 16, 2021

When will there be a fix for this?

@serverwentdown
Copy link
Contributor

serverwentdown commented Nov 16, 2021

@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/[email protected]

jonapich added a commit to coveooss/coveo-python-oss that referenced this issue Nov 17, 2021
python-poetry/poetry#4479 (comment) affects poetry 1.1.9, 1.1.10 and 1.1.11, will be fixed in 1.1.12
edvardm pushed a commit to edvardm/poetry that referenced this issue Nov 24, 2021
Closes python-poetry#4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use `Link` and `url_to_path`.
@lululukas
Copy link
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/[email protected]

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.

@serverwentdown
Copy link
Contributor

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

@lululukas
Copy link
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!

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
@mbardwell
Copy link

mbardwell commented Sep 15, 2023

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

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants