question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running poetry install fails sometimes with new-installer

See original GitHub issue

Issue

At random, poetry install will fail with the following error. The package being installed by pip changes, but the brotli error doesn’t change.

  EnvCommandError

  Command ['/home/runner/work/poetry-test/poetry-test/.venv/bin/pip', 'install', '--no-deps', '/home/runner/.cache/pypoetry/artifacts/6c/0f/ea/fb7dbaaaac5e39918d0139753cfaeab4348e2b4f652e4c43e63e41db21/cchardet-2.1.7-cp38-cp38-manylinux2010_x86_64.whl'] errored with the following return code 1, and output: 
  Traceback (most recent call last):
    File "/home/runner/work/poetry-test/poetry-test/.venv/bin/pip", line 8, in <module>
      sys.exit(main())
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
      command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
      module = importlib.import_module(module_path)
    File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
    File "<frozen importlib._bootstrap>", line 991, in _find_and_load
    File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 783, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 17, in <module>
      from pip._internal.cli.req_command import RequirementCommand, with_cleanup
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 16, in <module>
      from pip._internal.index.collector import LinkCollector
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 14, in <module>
      from pip._vendor import html5lib, requests
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_vendor/requests/__init__.py", line 43, in <module>
      from pip._vendor import urllib3
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_vendor/urllib3/__init__.py", line 7, in <module>
      from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py", line 39, in <module>
      from .response import HTTPResponse
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 156, in <module>
      class HTTPResponse(io.IOBase):
    File "/home/runner/work/poetry-test/poetry-test/.venv/lib/python3.8/site-packages/pip/_vendor/urllib3/response.py", line 389, in HTTPResponse
      DECODER_ERROR_CLASSES += (brotli.error,)
  AttributeError: module 'brotli' has no attribute 'error'
  

  at ~/.poetry/lib/poetry/utils/env.py:1074 in _run
      1070│                 output = subprocess.check_output(
      1071│                     cmd, stderr=subprocess.STDOUT, **kwargs
      1072│                 )
      1073│         except CalledProcessError as e:
    → 1074│             raise EnvCommandError(e, input=input_)
      1075│ 
      1076│         return decode(output)
      1077│ 
      1078│     def execute(self, bin, *args, **kwargs):

So far it doesn’t seem to happen from a normal interactive shell on macOS, but that could just be random luck. However CI at work in Jenkins has been flaky and even local builds in Docker show the same issue.

What seems to fix it is setting new-installer = false.

I realize there are already a few issues opened that are possibly similar (related to race conditions and parallel installs), but I was able to replicate it in an example GitHub action so figured maybe that could help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
dlouzancommented, May 4, 2021

We’ve encountered this also running our builds on gitlab-ci, randomly builds will fail, not only running directly on the runner docker executor, also inside kaniko builds. The only solution has been to disable the new installer as documented above:

poetry config experimental.new-installer false
1reaction
benjaminsweetnam247commented, Feb 8, 2022

can we make the experimental not the default this has been driving me nuts for days thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry install fails with EnvCommandError: looks for version ...
I had this same error because for some reason poetry install always failed to create a virtual enviroment path in %APPDATA% .
Read more >
Configuration | Documentation | Poetry - Python dependency ...
Sometimes, in particular when using Poetry with CI tools, it's easier to use ... This configuration is only respected when using the new...
Read more >
Announcing Poetry 1.2.0 -- Python dependency management ...
https://github.com/python-poetry/poetry/issues/6377 ... Can this be fixed by just switching to the new installer?
Read more >
Dependency Management With Python Poetry
Even worse, external packages often rely on specific Python versions. Consequently, a user installing your package might get an error because ...
Read more >
Python package installation issues with Poetry - Medium
My project.toml wanted to install scikit-learn v0.23.2 but somehow would fail with the following message every time i tried to run poetry update...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found