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

AssertionError from poetry add Naked #1985

Closed
3 tasks done
shangxiao opened this issue Feb 6, 2020 · 13 comments
Closed
3 tasks done

AssertionError from poetry add Naked #1985

shangxiao opened this issue Feb 6, 2020 · 13 comments
Assignees
Labels
area/error-handling Bad error messages/insufficient error handling area/solver Related to the dependency resolver

Comments

@shangxiao
Copy link

  • 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: macOS 1015.3 Catalina

  • Poetry version: 1.0.3

  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/shangxiao/50d1f8aa24157a14f759110b552df202

Issue

Running poetry add Naked results in an AssertionError

$ poetry add -vvv Naked
Using virtualenv: /Users/someuser/Library/Caches/pypoetry/virtualenvs/poetry-test-oO20IG-_-py3.6
PyPI: No release information found for Naked-0.1.9, skipping
PyPI: 19 packages found for Naked *
Using version ^0.1.31 for Naked

Updating dependencies
Resolving dependencies...
   1: fact: poetry-test is 0.1.0
   1: derived: poetry-test
   1: fact: poetry-test depends on Naked (^0.1.31)
   1: fact: poetry-test depends on pytest (^5.2)
   1: fact: poetry-test depends on pytest (^5.2)
   1: selecting poetry-test (0.1.0)
   1: derived: pytest (^5.2)
   1: derived: Naked (^0.1.31)
PyPI: 11 packages found for pytest >=5.2,<6.0
PyPI: No release information found for naked-0.1.9, skipping
PyPI: 1 packages found for naked >=0.1.31,<0.2.0
   1: Version solving took 0.030 seconds.
   1: Tried 1 solutions.

[AssertionError]


Traceback (most recent call last):
  File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/someuser/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/someuser/.poetry/lib/poetry/console/commands/add.py", line 149, in handle
    status = installer.run()
  File "/Users/someuser/.poetry/lib/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/Users/someuser/.poetry/lib/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/Users/someuser/.poetry/lib/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/Users/someuser/.poetry/lib/poetry/puzzle/solver.py", line 181, in _solve
    self._package, self._provider, locked=locked, use_latest=use_latest
  File "/Users/someuser/.poetry/lib/poetry/mixology/__init__.py", line 7, in resolve_version
    return solver.solve()
  File "/Users/someuser/.poetry/lib/poetry/mixology/version_solver.py", line 80, in solve
    next = self._choose_package_version()
  File "/Users/someuser/.poetry/lib/poetry/mixology/version_solver.py", line 381, in _choose_package_version
    for incompatibility in self._provider.incompatibilities_for(version):
  File "/Users/someuser/.poetry/lib/poetry/puzzle/provider.py", line 529, in incompatibilities_for
    for dep in dependencies
  File "/Users/someuser/.poetry/lib/poetry/puzzle/provider.py", line 529, in <listcomp>
    for dep in dependencies
  File "/Users/someuser/.poetry/lib/poetry/mixology/incompatibility.py", line 60, in __init__
    assert by_ref[ref] is not None
@shangxiao shangxiao added the kind/bug Something isn't working as expected label Feb 6, 2020
@shangxiao
Copy link
Author

Update:

I discovered why this is occurring: There's a reported issue where Naked was listed as a dependency in its own package requirements: chrissimpkins/naked#19

The fix is in master but not released (as of 0.1.31)

@Darel13712
Copy link

Darel13712 commented Apr 8, 2020

I have the same problem with adding my package with poetry add. This assertion error is not informative in the slightest. If it would at least say which package has cyclic dependency it would be more useful.

I have a dependency on datatable which has a dependency on typesentry which states inself in install_requires.

I was able to find this installing my package into a clear venv and using pipdeptree which gave me

Warning!! Cyclic dependencies found:
* typesentry => typesentry => typesentry

But is there another solution rather than making PRs to each individual package to fix this? This dependency loop is trivial and can be ignored on poetry level. Wouldn't it be better solution?

@finswimmer finswimmer added the area/solver Related to the dependency resolver label Apr 8, 2020
@gaozhidf
Copy link

poetry add -vvv pystray meets the same problem.

Using virtualenv: /Users/abaaba/Library/Caches/pypoetry/virtualenvs/pystray-jVTnuic3-py3.7
PyPI: No release information found for pystray-0.1, skipping
PyPI: 24 packages found for pystray *
Using version ^0.16.0 for pystray

Updating dependencies
Resolving dependencies...
   1: fact: pystray is 0.1.0
   1: derived: pystray
   1: Version solving took 0.005 seconds.
   1: Tried 1 solutions.

[AssertionError]


Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/local/lib/python3.7/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/local/lib/python3.7/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/local/lib/python3.7/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/local/lib/python3.7/site-packages/poetry/console/commands/add.py", line 156, in handle
    status = installer.run()
  File "/usr/local/lib/python3.7/site-packages/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/usr/local/lib/python3.7/site-packages/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/usr/local/lib/python3.7/site-packages/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/usr/local/lib/python3.7/site-packages/poetry/puzzle/solver.py", line 181, in _solve
    self._package, self._provider, locked=locked, use_latest=use_latest
  File "/usr/local/lib/python3.7/site-packages/poetry/mixology/__init__.py", line 7, in resolve_version
    return solver.solve()
  File "/usr/local/lib/python3.7/site-packages/poetry/mixology/version_solver.py", line 80, in solve
    next = self._choose_package_version()
  File "/usr/local/lib/python3.7/site-packages/poetry/mixology/version_solver.py", line 392, in _choose_package_version
    self._add_incompatibility(incompatibility)
  File "/usr/local/lib/python3.7/site-packages/poetry/mixology/version_solver.py", line 431, in _add_incompatibility
    self._log('fact: {}'.format(incompatibility))
  File "/usr/local/lib/python3.7/site-packages/poetry/mixology/incompatibility.py", line 111, in __str__
    assert len(self._terms) == 2

@MatheusR42
Copy link

I think that I get the same problem with networkx.

$  poetry add networkx -vvv
Using virtualenv: /home/matheusr42/.cache/pypoetry/virtualenvs/networkx-E6832TF_-py3.8
PyPI: No release information found for networkx-0.23, skipping
PyPI: No release information found for networkx-0.24, skipping
PyPI: No release information found for networkx-0.25, skipping
PyPI: No release information found for networkx-0.26, skipping
PyPI: No release information found for networkx-0.27, skipping
PyPI: No release information found for networkx-0.28, skipping
PyPI: No release information found for networkx-0.29, skipping
PyPI: No release information found for networkx-0.30, skipping
PyPI: No release information found for networkx-0.31, skipping
PyPI: No release information found for networkx-0.32, skipping
PyPI: No release information found for networkx-0.33, skipping
PyPI: 27 packages found for networkx *
Using version ^2.5 for networkx

Updating dependencies
Resolving dependencies...
   1: fact: networkx is 0.1.0
   1: derived: networkx
   1: Version solving took 0.002 seconds.
   1: Tried 1 solutions.

  Stack trace:

  13  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py:131 in run
       129│             parsed_args = resolved_command.args
       130│ 
     → 131│             status_code = command.handle(parsed_args, io)
       132│         except KeyboardInterrupt:
       133│             status_code = 1

  12  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:120 in handle
       118│     def handle(self, args, io):  # type: (Args, IO) -> int
       119│         try:
     → 120│             status_code = self._do_handle(args, io)
       121│         except KeyboardInterrupt:
       122│             if io.is_debug():

  11  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:171 in _do_handle
       169│         handler_method = self._config.handler_method
       170│ 
     → 171│         return getattr(handler, handler_method)(args, io, self)
       172│ 
       173│     def __repr__(self):  # type: () -> str

  10  ~/.poetry/lib/poetry/_vendor/py3.8/cleo/commands/command.py:92 in wrap_handle
        90│         self._command = command
        91│ 
     →  92│         return self.handle()
        93│ 
        94│     def handle(self):  # type: () -> Optional[int]

   9  ~/.poetry/lib/poetry/console/commands/add.py:174 in handle
       172│ 
       173│         try:
     → 174│             status = self._installer.run()
       175│         except Exception:
       176│             self.poetry.file.write(original_content)

   8  ~/.poetry/lib/poetry/installation/installer.py:99 in run
        97│         local_repo = Repository()
        98│ 
     →  99│         return self._do_install(local_repo)
       100│ 
       101│     def dry_run(self, dry_run=True):  # type: (bool) -> Installer

   7  ~/.poetry/lib/poetry/installation/installer.py:205 in _do_install
       203│             )
       204│ 
     → 205│             ops = solver.solve(use_latest=self._whitelist)
       206│         else:
       207│             self._io.write_line("Installing dependencies from lock file")

   6  ~/.poetry/lib/poetry/puzzle/solver.py:65 in solve
        63│         with self._provider.progress():
        64│             start = time.time()
     →  65│             packages, depths = self._solve(use_latest=use_latest)
        66│             end = time.time()
        67│ 

   5  ~/.poetry/lib/poetry/puzzle/solver.py:233 in _solve
       231│ 
       232│         try:
     → 233│             result = resolve_version(
       234│                 self._package, self._provider, locked=locked, use_latest=use_latest
       235│             )

   4  ~/.poetry/lib/poetry/mixology/__init__.py:7 in resolve_version
       5│     solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
       6│ 
     → 7│     return solver.solve()
       8│ 

   3  ~/.poetry/lib/poetry/mixology/version_solver.py:84 in solve
        82│             while next is not None:
        83│                 self._propagate(next)
     →  84│                 next = self._choose_package_version()
        85│ 
        86│             return self._result()

   2  ~/.poetry/lib/poetry/mixology/version_solver.py:401 in _choose_package_version
       399│         conflict = False
       400│         for incompatibility in self._provider.incompatibilities_for(version):
     → 401│             self._add_incompatibility(incompatibility)
       402│ 
       403│             # If an incompatibility is already satisfied, then selecting version

   1  ~/.poetry/lib/poetry/mixology/version_solver.py:442 in _add_incompatibility
       440│ 
       441│     def _add_incompatibility(self, incompatibility):  # type: (Incompatibility) -> None
     → 442│         self._log("fact: {}".format(incompatibility))
       443│ 
       444│         for term in incompatibility.terms:

  AssertionError

  

  at ~/.poetry/lib/poetry/mixology/incompatibility.py:111 in __str__
      107│         )
      108│ 
      109│     def __str__(self):
      110│         if isinstance(self._cause, DependencyCause):
    → 111│             assert len(self._terms) == 2
      112│ 
      113│             depender = self._terms[0]
      114│             dependee = self._terms[1]
      115│             assert depender.is_positive()

@abn
Copy link
Member

abn commented Oct 3, 2020

@MadHatt3rs this succeeds for me in 1.1.0

$ [email protected] add networkx
Using version ^2.5 for networkx

Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 2 installs, 0 updates, 0 removals

  • Installing decorator (4.4.2)
  • Installing networkx (2.5)

@gaozhidf so does pystray

$ [email protected] add pystray
Using version ^0.17.1 for pystray

Updating dependencies
Resolving dependencies... (1.2s)

Writing lock file

Package operations: 4 installs, 0 updates, 0 removals

  • Installing six (1.15.0)
  • Installing pillow (7.2.0)
  • Installing python-xlib (0.28)
  • Installing pystray (0.17.1)

Regardig the assertion error, I agree this needs to be improved.

@MatheusR42
Copy link

@abn , I was using version 1.1.0, but I realized that the problem is that I created a new project with same name of the package. I did this 😅 :


$ poetry new networkx
Created package networkx in networkx
$ cd networkx/
$ poetry add networkx
Creating virtualenv networkx-ij1fzQR9-py3.8 in /home/matheusr42/.cache/pypoetry/virtualenvs
Using version ^2.5 for networkx

Updating dependencies
Resolving dependencies... (0.0s)

  AssertionError

  

  at ~/.poetry/lib/poetry/mixology/incompatibility.py:111 in __str__
      107│         )
      108│ 
      109│     def __str__(self):
      110│         if isinstance(self._cause, DependencyCause):
    → 111│             assert len(self._terms) == 2
      112│ 
      113│             depender = self._terms[0]
      114│             dependee = self._terms[1]
      115│             assert depender.is_positive()

I tried with another project name and it works, thanks! 😁 I think that it is not a big problem, but will be nice if there is a warn message.

@abn
Copy link
Member

abn commented Oct 5, 2020

@sdispater can we get these, original issue and cyclic dependencies, propagated as a SolverError?

@abn abn added area/error-handling Bad error messages/insufficient error handling and removed kind/bug Something isn't working as expected labels Oct 17, 2020
@hugohjerten
Copy link

@MatheusR42 I did the same mistake as you did! Silly for sure, but would be nice if there was an alternative error handling when installing a package that has the same name as the project 😅

@michaeljones
Copy link

I made the same mistake as @MatheusR42. I wanted to play around with py2app so I made a project callec py2app. I didn't know that would break things. Certainly would appreciate a better message than the line 111 AssertionError. Love Poetry otherwise though :)

@chipytux
Copy link

@gaozhidf, You cannot create a project with the same name of a module dependency.
You have create a project name called pystray and import pystray module in your dependencies list. This will be raise an error.

@yatmanov
Copy link

I have faced the same problem using version 1.1.12. IMHO, just a simple message explaining the cause would do much better than empty AssertionError.

@dimbleby
Copy link
Contributor

Today:

$ poetry add [email protected]

Updating dependencies
Resolving dependencies... Downloading https://files.pythonhosted.org/packages/02/36/b8107b51adca73402ec1860d88f41d958e275e60eea6eeaa9c39ddb89a40/Naked-0.1.31-py2.py3-none-any.whl (0.3s)

Package 'naked' is listed as a dependency of itself.

seems good to close

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
area/error-handling Bad error messages/insufficient error handling area/solver Related to the dependency resolver
Projects
None yet
Development

No branches or pull requests