poetry: Installing packages fails when already cached on Windows (making 1.1.9+ unusable on Windows)

  • 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.1.9-1.1.11
  • Link of a Gist with the contents of your pyproject.toml file:
name = "poetry_test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.6"
lxml = "^4.6.3"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Issue

Installing a package that is already in the local pypoetry cache on windows fails since poetry 1.1.9.

$ poetry install -vvv --no-root
Using virtualenv: D:\user\src\temp\poetry_test\poetry_env
Installing dependencies from lock file

Finding the necessary packages for the current system

Package operations: 1 install, 0 updates, 0 removals

  • Installing lxml (4.6.3): Pending...
  • Installing lxml (4.6.3): Failed

  ValueError

  File \C:\Users\user\AppData\Local\pypoetry\Cache\artifacts\f7\90\e7\2d9752b05431b2ba90b4626b90f1674c505301a7cdbab89fd620aee824\lxml-4.6.3-cp36-cp36m-win_amd64.whl does not exist

  at D:\user\src\temp\poetry_test\poetry_env\lib\site-packages\poetry\core\packages\file_dependency.py:40 in __init__
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))
       38│
       39│         if not self._full_path.exists():
    →  40│             raise ValueError("File {} does not exist".format(self._path))
       41│
       42│         if self._full_path.is_dir():
       43│             raise ValueError("{} is a directory, expected a file".format(self._path))
       44│

The problem does not occur, if the package is not cached.

Python version used is 3.6.8

Workaround

As a workaround we downgraded to 1.1.8 and poetry-core 1.0.4.

IMHO

It seems like this issue comes from the commit https://github.com/python-poetry/poetry/commit/8238cab2e1690b4e1b7ea4a460c6295b1b2c6cb7

The call to “archive.path” in line 615 of ‘poetry/installation/executor.py’ seems to remove only two of the three slashes for Windows file URLs (file:///c:/…). This results in an invalid path with a leading slash (visible in the command output File \C:\Users\user\AppData), which in the end leads to a missing file exception.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 14
  • Comments: 26 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I’m surprised this is allowed to go on for over a month. This makes poetry 100% unusable on windows. In fact, even downgrading doesn’t help if you’re on the newest version of python because there’s a fix for that in poetry 1.1.10.

I have a similar problem when poetry tries to install colorama

Package operations: 10 installs, 0 updates, 0 removals

  • Installing colorama (0.4.4)

  ValueError

  File \C:\Users\Admin\AppData\Local\pypoetry\Cache\artifacts\9e\b3\11\7d87ac44fdb2d557301f1f4086a37c080d1482a98751abe7cdbabbad26\colorama-0.4.4-py2.py3-none-any.whl does not exist

  at ~\.poetry\lib\poetry\_vendor\py3.9\poetry\core\packages\file_dependency.py:40 in __init__
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))
       38│
       39│         if not self._full_path.exists():
    →  40│             raise ValueError("File {} does not exist".format(self._path))
       41│
       42│         if self._full_path.is_dir():
       43│             raise ValueError("{} is a directory, expected a file".format(self._path))
       44│

Windows 10 19043.1237 Python 3.9.7 Poetry 1.1.10 Poetry-core 1.0.6

I have this issue and need to constantly delete my ~\AppData\Local\pypoetry\Cache\artifacts folder to fix the issue when updating dependencies. Any update on whether or not a release will come soon that will have a patch for this issue? (using 1.1.11)

@pohlt Wait a while for the next release. In the meantime, you can install the 1.2 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@master

For those with this issue, the following fix worked for me:

  • Open ~\.poetry\lib\poetry\_vendor\py3.8\poetry\core\packages\utils\link.py (may need to change python version)
  • Add import urllib.request at the top
  • Modify Link.path to look like the following:

    @property
    def path(self):  # type: () -> str
        res = urlparse.urlsplit(self.url)
        if res.scheme == 'file':
            netloc = res.netloc
            if netloc:
                netloc = '\\\\' + netloc
            return urllib.request.url2pathname(netloc + res.path)
        else:
            return urlparse.unquote(res.path)

This seems quite a bit simpler than the “fix” PR?

Will be fixed by #4531 (1.2) and #4549 (1.1)

@pohlt Wait a while for the next release. In the meantime, you can install the 1.2 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@master

This gives me an error

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

Removing the git+ works, though:

(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

@rubendibattista I don’t think so, that issue seems to be due to some other reason, not Paths starting with slashes.

Tested with 1.1.10, same problem.

A pull request that seems to fix this issue: https://github.com/python-poetry/poetry/pull/4531

I am having the same issue on github’s CI Windows machine.