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

Link object being passed instead of Path to poetry.core.packages.file_dependency.FileDependency in poetry-core 1.0.5 #4541

Closed
3 tasks done
mrogaski opened this issue Sep 22, 2021 · 14 comments
Labels
kind/bug Something isn't working as expected

Comments

@mrogaski
Copy link

mrogaski commented Sep 22, 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).
X:\poetry-core>pip freeze | grep poetry
poetry==1.1.8
poetry-core==1.0.5

X:\poetry-core>poetry debug

Poetry
Version: 1.1.8
Python:  3.9.4

Virtualenv
Python:         3.9.4
Implementation: CPython
Path:           X:\poetry-core\.venv
Valid:          True

System
Platform: win32
OS:       nt
Python:   c:\users\mrogaski\appdata\local\programs\python\python39

X:\poetry-core>poetry config --list
cache-dir = "C:\\Users\\mrogaski\\AppData\\Local\\pypoetry\\Cache"
experimental.new-installer = true
installer.parallel = true
settings.virtualenvs.create = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\mrogaski\AppData\Local\pypoetry\Cache\virtualenvs

Issue

I can easily reproduce the issue moving from poetry-core 1.0.4 to 1.0.5, where I have the project directory and the Poetry cache directory on separate volumes (where there is no absolute path to the cache directory from the CWD). I can also reproduce the problem where the cache and CWD are co-located on a drive mapped with the SUBST command, likely because the cache is showing up as being on a different volume.

This is in a freshly cloned poetry-core project.

X:\poetry-core>poetry install
Creating virtualenv poetry-core in X:\poetry-core\.venv
Installing dependencies from lock file

Package operations: 41 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)

  AttributeError

  'Link' object has no attribute 'is_absolute'

  at c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\core\packages\file_dependency.py:33 in __init__
       29│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))


  AttributeError

  'Link' object has no attribute 'is_absolute'

  at c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\core\packages\file_dependency.py:33 in __init__
       29│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))

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

X:\poetry-core>poetry install -vvv
Using virtualenv: X:\poetry-core\.venv
Installing dependencies from lock file

Finding the necessary packages for the current system

Package operations: 41 installs, 0 updates, 0 removals, 4 skipped

  • Removing dataclasses (0.8): Skipped for the following reason: Not currently installed
  • Removing importlib-metadata (4.0.1): Skipped for the following reason: Not currently installed
  • Removing importlib-resources (5.1.2): Skipped for the following reason: Not currently installed
  • Removing zipp (3.4.1): Skipped for the following reason: Not currently installed
  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)

  Stack trace:

  6  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:202 in _execute_operation
      200│
      201│             try:
    → 202│                 result = self._do_execute_operation(operation)
      203│             except EnvCommandError as e:
      204│                 if e.e.returncode == -2:

  5  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:276 in _do_execute_operation
      274│             return 0
      275│
    → 276│         result = getattr(self, "_execute_{}".format(method))(operation)
      277│
      278│         if result != 0:

  4  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:411 in _execute_install
      409│
      410│     def _execute_install(self, operation):  # type: (Install) -> None
    → 411│         return self._install(operation)
      412│
      413│     def _execute_update(self, operation):  # type: (Update) -> None

  3  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:437 in _install
      435│             archive = self._download_link(operation, Link(package.source_url))
      436│         else:
    → 437│             archive = self._download(operation)
      438│
      439│         operation_message = self.get_operation_message(operation)

  2  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:585 in _download
      583│         link = self._chooser.choose_for(operation.package)
      584│
    → 585│         return self._download_link(operation, link)
      586│
      587│     def _download_link(self, operation, link):

  1  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:611 in _download_link
      609│
      610│         if package.files:
    → 611│             archive_hash = "sha256:" + FileDependency(package.name, archive).hash()
      612│             if archive_hash not in {f["hash"] for f in package.files}:
      613│                 raise RuntimeError(

  AttributeError

  'Link' object has no attribute 'is_absolute'

  at c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\core\packages\file_dependency.py:33 in __init__
       29│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))


  Stack trace:

  6  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:202 in _execute_operation
      200│
      201│             try:
    → 202│                 result = self._do_execute_operation(operation)
      203│             except EnvCommandError as e:
      204│                 if e.e.returncode == -2:

  5  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:276 in _do_execute_operation
      274│             return 0
      275│
    → 276│         result = getattr(self, "_execute_{}".format(method))(operation)
      277│
      278│         if result != 0:

  4  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:411 in _execute_install
      409│
      410│     def _execute_install(self, operation):  # type: (Install) -> None
    → 411│         return self._install(operation)
      412│
      413│     def _execute_update(self, operation):  # type: (Update) -> None

  3  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:437 in _install
      435│             archive = self._download_link(operation, Link(package.source_url))
      436│         else:
    → 437│             archive = self._download(operation)
      438│
      439│         operation_message = self.get_operation_message(operation)

  2  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:585 in _download
      583│         link = self._chooser.choose_for(operation.package)
      584│
    → 585│         return self._download_link(operation, link)
      586│
      587│     def _download_link(self, operation, link):

  1  c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\installation\executor.py:611 in _download_link
      609│
      610│         if package.files:
    → 611│             archive_hash = "sha256:" + FileDependency(package.name, archive).hash()
      612│             if archive_hash not in {f["hash"] for f in package.files}:
      613│                 raise RuntimeError(

  AttributeError

  'Link' object has no attribute 'is_absolute'

  at c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\core\packages\file_dependency.py:33 in __init__
       29│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))

@RomainBrault
Copy link

RomainBrault commented Sep 23, 2021

Same here! I have to empty my .cache/pypoetry to make it work.

Resolving dependencies... (66.1s)                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                        
Writing lock file                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                        
Package operations: 175 installs, 11 updates, 0 removals                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • Updating pyrsistent (0.14.11 -> 0.18.0): Failed                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  AttributeError                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  'Link' object has no attribute 'is_absolute'                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  at ~/miniforge3/envs/awesome_project/lib/python3.9/site-packages/poetry/core/packages/file_dependency.py:33 in __init__                                                                                                                                                                                                                                                                                                        
       29│         self._path = path                                                                                                                                                                                                                                                                                                                                                                                                    
       30│         self._base = base or Path.cwd()                                                                                                                                                                                                                                                                                                                                                                                      
       31│         self._full_path = path                                                                                                                                                                                                                                                                                                                                                                                               
       32│                                                                                                                                                                                                                                                                                                                                                                                                                              
    →  33│         if not self._path.is_absolute():                                                                                                                                                                                                                                                                                                                                                                                     
       34│             try:                                                                                                                                                                                                                                                                                                                                                                                                             
       35│                 self._full_path = self._base.joinpath(self._path).resolve()                                                                                                                                                                                                                                                                                                                                                  
       36│             except FileNotFoundError:                                                                                                                                                                                                                                                                                                                                                                                        
       37│                 raise ValueError("Directory {} does not exist".format(self._path))                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • Installing traitlets (5.1.0): Failed                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  AttributeError                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  'Link' object has no attribute 'is_absolute'                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                        
  at ~/miniforge3/envs/awesome_project/lib/python3.9/site-packages/poetry/core/packages/file_dependency.py:33 in __init__                                                                                                                                                                                                                                                                                                        
       29│         self._path = path                                                                                                                                                                                                                                                                                                                                                                                                    
       30│         self._base = base or Path.cwd()                                                                                                                                                                                                                                                                                                                                                                                      
       31│         self._full_path = path                                                                                                                                                                                                                                                                                                                                                                                               
       32│                                                                                                                                                                                                                                                                                                                                                                                                                              
    →  33│         if not self._path.is_absolute():                                                                                                                                                                                                                                                                                                                                                                                     
       34│             try:                                                                                                                                                                                                                                                                                                                                                                                                             
       35│                 self._full_path = self._base.joinpath(self._path).resolve()                                                                                                                                                                                                                                                                                                                                                  
       36│             except FileNotFoundError:                                                                                                                                                                                                                                                                                                                                                                                        
       37│                 raise ValueError("Directory {} does not exist".format(self._path))                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                        
ERROR: Stopping generation because p

@mrogaski
Copy link
Author

Clearing the cache hasn't changed the behavior I'm experiencing. But the fact that that the Link object is being passed indicates that there's a commonality.

@nvxf
Copy link

nvxf commented Sep 28, 2021

I had the same issue because I had recently pinned poetry but not poetry-core.

I had poetry pinned to 1.1.7, which worked with poetry-core-1.0.5. After poetry-core was updated to 1.0.6, poetry 1.1.7 stopped working and starts to exhibit the behaviour described above.

@mrogaski Seeing that you are using poetry-core-1.0.5 try to update poetry-core to 1.0.6 and see if that solves that issue for you, too.

@Cilyan
Copy link

Cilyan commented Sep 29, 2021

Thanks for this last comment, indeed I did not notice that poetry-core was not locked if I lock poetry itself. And this resulted in poetry-core version slowly drifting until it was no longer compatible. This looks like yet another hole in the net somehow, though?

@mrogaski
Copy link
Author

mrogaski commented Sep 29, 2021

No, 1.0.6 is also impacted.

X:\poetry-core>pip freeze | grep poetry
poetry==1.1.8
poetry-core==1.0.6

X:\poetry-core>poetry install
Installing dependencies from lock file

Package operations: 41 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)

  AttributeError

  'Link' object has no attribute 'is_absolute'

  at c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\core\packages\file_dependency.py:33 in __init__
       29│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))


  AttributeError

  'Link' object has no attribute 'is_absolute'

  at c:\users\mrogaski\appdata\local\programs\python\python39\lib\site-packages\poetry\core\packages\file_dependency.py:33 in __init__
       29│         self._path = path
       30│         self._base = base or Path.cwd()
       31│         self._full_path = path
       32│
    →  33│         if not self._path.is_absolute():
       34│             try:
       35│                 self._full_path = self._base.joinpath(self._path).resolve()
       36│             except FileNotFoundError:
       37│                 raise ValueError("Directory {} does not exist".format(self._path))

X:\poetry-core>pip freeze | grep poetry
poetry==1.1.10
poetry-core==1.0.6

X:\poetry-core>poetry install
Installing dependencies from lock file

Package operations: 41 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing six (1.15.0)

  ValueError

  File \C:\Users\mrogaski\AppData\Local\pypoetry\Cache\artifacts\dd\1c\65\ad0dea11136f5a869f072890a0eea955aa8fc35b90c85c55249fd3abfe\six-1.15.0-py2.py3-none-any.whl does not exist

  at c:\users\mrogaski\appdata\local\programs\python\python39\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│


  ValueError

  File \C:\Users\mrogaski\AppData\Local\pypoetry\Cache\artifacts\92\0f\cf\effdcd5d76a6186df0969f85b3b030284ff8058936d5016540b5258ea3\pyparsing-2.4.7-py2.py3-none-any.whl does not exist

  at c:\users\mrogaski\appdata\local\programs\python\python39\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│



@ReinierKop
Copy link

Also experiencing this on poetry 1.1.8 + core 1.0.5. Downgrading to 1.1.7 and core 1.0.4 resolved my issue

@mbergal
Copy link

mbergal commented Oct 8, 2021

Is it possible to install poetry using poetry itself. This would help since poetry respects lock file and would consistently install core 1.0.3 instead of whatever is available at the time of install?

I would install latest poetry into separate location and use it to install the specific poetry version in my environment.

@serverwentdown
Copy link
Contributor

Can you ckeck if #4531 fixes this for you?

@mrogaski
Copy link
Author

mrogaski commented Oct 9, 2021

Can you ckeck if #4531 fixes this for you?

This appears to fix the issue. I was able to reproduce the behavior from the 1.2.0a2 master and I don't encounter the problem with the fix applied.

@vvoody
Copy link

vvoody commented Oct 15, 2021

I found rm -rf ~/Library/Caches/pypoetry/* work, poetry 1.1.11 and poetry-core 1.0.7.

danbentley added a commit to nationalarchives/ds-wagtail that referenced this issue Jan 10, 2022
`poetry install` raised: `AttributeError: 'Link' object has no attribute
'is_absolute'` during build on platform.sh.

It appears that it's possible for poetry-core to update even if poetry
is locked. Our issue wasa caused by a regression introduced in 1.0.4.

Updated poetry following the advice in the linked github issue and
updated pip to fix an issue selecting the correct wheel for cryptography
36.0.0 on platform.sh.

Locked Poetry to 1.1.12 and pip to 21.3.1 for docker and platform.sh

Related issues:

 - [Link object being passed instead of Path to poetry.core.packages.file_dependency.FileDependency in poetry-core 1.0.5](python-poetry/poetry#4541)
 - [fix: Broken cache on Windows #4531](python-poetry/poetry#4531)
danbentley added a commit to nationalarchives/ds-wagtail that referenced this issue Jan 10, 2022
`poetry install` raised: `AttributeError: 'Link' object has no attribute
'is_absolute'` during build on platform.sh.

It appears that it's possible for poetry-core to update even if poetry
is locked. Our issue wasa caused by a regression introduced in 1.0.4.

Updated poetry following the advice in the linked github issue and
updated pip to fix an issue selecting the correct wheel for cryptography
`36.0.0` on platform.sh.

Locked Poetry to `1.1.12` and pip to `21.3.1` for docker and platform.sh

Related issues:

 - [Link object being passed instead of Path to poetry.core.packages.file_dependency.FileDependency in poetry-core 1.0.5](python-poetry/poetry#4541)
 - [fix: Broken cache on Windows #4531](python-poetry/poetry#4531)
@papb
Copy link

papb commented Mar 15, 2022

The solution in my case (poetry 1.1.6) was to run rm -rf $HOME/.cache/pypoetry/artifacts/* before poetry install.

folkyatina pushed a commit to lidofinance/AVotesParser that referenced this issue Apr 12, 2022
@radoering
Copy link
Member

Should be fixed via #4531 (poetry 1.2.0b1) and #4549 (poetry 1.1.12).

@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Jun 11, 2022
Copy link

github-actions bot commented Mar 1, 2024

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 Mar 1, 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.