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_VIRTUALENVS_CREATE=false breaks poetry 1.2.0a2 #4430

Closed
3 tasks done
1ace opened this issue Aug 23, 2021 · 3 comments
Closed
3 tasks done

POETRY_VIRTUALENVS_CREATE=false breaks poetry 1.2.0a2 #4430

1ace opened this issue Aug 23, 2021 · 3 comments
Labels
kind/bug Something isn't working as expected

Comments

@1ace
Copy link
Contributor

1ace commented Aug 23, 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: docker image python:3.7-slim (debian-based)

  • Poetry version: 1.2.0a2

  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/a53c402eaab6b1ae204019624972fb44
    ☝️ contains the pyproject.toml & poetry.lock, as well as a minimal Dockerfile which reproduces the issue. Simply run docker build . to reproduce locally.

Issue

When POETRY_VIRTUALENVS_CREATE=false is set, poetry breaks itself during poetry install, as can be seen with the reproducer provided.

click to show the poetry exception stack trace

 > [6/6] RUN poetry -vvv export:
#10 0.360
#10 0.360   ImportError
#10 0.360
#10 0.360   cannot import name 'metadata' from 'importlib' (/usr/local/lib/python3.7/importlib/__init__.py)
#10 0.360
#10 0.360   at ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/poetry/utils/_compat.py:5 in <module>
#10 0.366         1│ import sys
#10 0.366         2│
#10 0.366         3│
#10 0.366         4│ try:
#10 0.366     →   5│     from importlib import metadata
#10 0.366         6│ except ImportError:
#10 0.366         7│     # compatibility for python <3.8
#10 0.366         8│     import importlib_metadata as metadata  # noqa
#10 0.366         9│
#10 0.394
#10 0.394 The following error occurred when trying to handle this error:
#10 0.394
#10 0.394
#10 0.394   Stack trace:
#10 0.395
#10 0.395   16  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/cleo/application.py:330 in run
#10 0.420        328│
#10 0.420        329│             try:
#10 0.420      → 330│                 exit_code = self._run(io)
#10 0.420        331│             except Exception as e:
#10 0.420        332│                 if not self._catch_exceptions:
#10 0.420
#10 0.421   15  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/poetry/console/application.py:180 in _run
#10 0.435        178│         self._load_plugins(io)
#10 0.435        179│
#10 0.435      → 180│         return super()._run(io)
#10 0.436        181│
#10 0.436        182│     def _configure_io(self, io: IO) -> None:
#10 0.436
#10 0.436   14  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/cleo/application.py:375 in _run
#10 0.461        373│             pass
#10 0.461        374│
#10 0.461      → 375│         name = self._get_command_name(io)
#10 0.461        376│         if io.input.has_parameter_option(["--help", "-h"], True):
#10 0.462        377│             if not name:
#10 0.462
#10 0.462   13  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/cleo/application.py:597 in _get_command_name
#10 0.490        595│
#10 0.490        596│             for candidate in reversed(candidates):
#10 0.490      → 597│                 if self.has(candidate):
#10 0.490        598│                     return candidate
#10 0.490        599│
#10 0.490
#10 0.490   12  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/cleo/application.py:235 in has
#10 0.516        233│
#10 0.516        234│         return self._command_loader.has(name) and self.add(
#10 0.516      → 235│             self._command_loader.get(name)
#10 0.516        236│         )
#10 0.516        237│
#10 0.516
#10 0.516   11  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/cleo/loaders/factory_command_loader.py:32 in get
#10 0.517         30│         factory = self._factories[name]
#10 0.517         31│
#10 0.517      →  32│         return factory()
#10 0.518         33│
#10 0.518
#10 0.518   10  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/poetry/console/application.py:38 in _load
#10 0.534         36│     def _load() -> Type[Command]:
#10 0.534         37│         module = import_module(
#10 0.534      →  38│             "poetry.console.commands.{}".format(".".join(name.split(" ")))
#10 0.534         39│         )
#10 0.534         40│         command_class = getattr(
#10 0.534
#10 0.534    9  /usr/local/lib/python3.7/importlib/__init__.py:127 in import_module
#10 0.541        125│                 break
#10 0.541        126│             level += 1
#10 0.541      → 127│     return _bootstrap._gcd_import(name[level:], package, level)
#10 0.541        128│
#10 0.541        129│
#10 0.541
#10 0.541    8  <frozen importlib._bootstrap>:1006 in _gcd_import
#10 0.541
#10 0.541    7  <frozen importlib._bootstrap>:983 in _find_and_load
#10 0.541
#10 0.541    6  <frozen importlib._bootstrap>:967 in _find_and_load_unlocked
#10 0.542
#10 0.542    5  <frozen importlib._bootstrap>:677 in _load_unlocked
#10 0.542
#10 0.542    4  <frozen importlib._bootstrap_external>:728 in exec_module
#10 0.542
#10 0.542    3  <frozen importlib._bootstrap>:219 in _call_with_frames_removed
#10 0.542
#10 0.542    2  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/poetry/console/commands/export.py:3 in <module>
#10 0.545          1│ from cleo.helpers import option
#10 0.545          2│
#10 0.546      →   3│ from poetry.utils.exporter import Exporter
#10 0.546          4│
#10 0.546          5│ from .command import Command
#10 0.546
#10 0.546    1  ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/poetry/utils/exporter.py:12 in <module>
#10 0.553         10│ from poetry.core.packages.utils.utils import path_to_url
#10 0.553         11│ from poetry.poetry import Poetry
#10 0.553      →  12│ from poetry.utils._compat import decode
#10 0.553         13│
#10 0.553         14│
#10 0.553
#10 0.553   ModuleNotFoundError
#10 0.553
#10 0.553   No module named 'importlib_metadata'
#10 0.554
#10 0.554   at ~/.local/share/pypoetry/venv/lib/python3.7/site-packages/poetry/utils/_compat.py:8 in <module>
#10 0.556         4│ try:
#10 0.556         5│     from importlib import metadata
#10 0.556         6│ except ImportError:
#10 0.556         7│     # compatibility for python <3.8
#10 0.556     →   8│     import importlib_metadata as metadata  # noqa
#10 0.556         9│
#10 0.556        10│ WINDOWS = sys.platform == "win32"
#10 0.556        11│
#10 0.556        12│
------
executor failed running [/bin/sh -c poetry -vvv export]: exit code: 1

Note that the same thing happens with various other libs (eg. requests) on various python versions (issue happens on 3.{7,8,9}, the 3 versions that we have to support); this is not about importlib_metadata or python 3.7.

I expect the same issue to arise with every lib that poetry also uses.

@1ace 1ace added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 23, 2021
@ajhynes7
Copy link

I found this issue from searching about the same problem. Poetry 1.2.0a2 failed for me when installing dependencies outside of a virtual environment in Docker.

@1ace
Copy link
Contributor Author

1ace commented Mar 18, 2022

As 1.2.0b1 just came out, I tried again and the bug seems to be fixed. Thank you to whoever did that 😄

Closing.

@1ace 1ace closed this as completed Mar 18, 2022
@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

No branches or pull requests

3 participants