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.

Possible race condition with poetry install inside docker

See original GitHub issue
  • 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).

Issue

I have noticed that after upgrading to poetry 1.1.x branch I started getting EnvCommandError errors when poetry is used inside docker.

 ---> Running in 97471832e9f0
Skipping virtualenv creation, as specified in config file.
Installing dependencies from lock file

Package operations: 120 installs, 0 updates, 0 removals

  • Installing pyasn1 (0.4.8)
  • Installing six (1.15.0)

  EnvCommandError

  Command ['/usr/local/bin/python', '-m', 'pip', 'install', '--no-deps', '/home/apps/.cache/pypoetry/artifacts/7b/3a/54/42ce43b579bda01b9d79022fb733811594441e7a32e9f9a5a98f672bdc/pyasn1-0.4.8-py2.py3-none-any.whl'] errored with the following return code 1, and output: 
  Looking in indexes: https://pypi.org/simple, https://****@xxx/pypi
  Processing /home/apps/.cache/pypoetry/artifacts/7b/3a/54/42ce43b579bda01b9d79022fb733811594441e7a32e9f9a5a98f672bdc/pyasn1-0.4.8-py2.py3-none-any.whl
  Installing collected packages: pyasn1
  ERROR: Could not install packages due to an EnvironmentError: [Errno 17] File exists: '/home/apps/.local/lib/python3.9/site-packages'
  
  

  at /opt/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):

Here the problem is with already existing /home/apps/.local/lib/python3.9/site-packages, but sometimes it points to other files in /home/apps/.local/ as well. Rerunning build without any changes usually ends with success.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:15
  • Comments:11

github_iconTop GitHub Comments

2reactions
jacek-jablonskicommented, Feb 16, 2021

here is my workaround:

RUN mkdir -p /home/xxx/.local/lib/python3.8/site-packages \
  && mkdir -p /home/xxx/.local/bin
2reactions
gwdekkercommented, Nov 11, 2020

Having a similar issue in a similar environment:

  • running poetry in docker in a CI pipeline
  • the error is intermittent, usually rerunning the job completes successfully.
Stack trace:
  7  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:199 in _execute_operation
     result = self._do_execute_operation(operation)
  6  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:273 in _do_execute_operation
     result = getattr(self, "_execute_{}".format(method))(operation)
  5  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:408 in _execute_install
     return self._install(operation)
  4  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:446 in _install
     return self.run_pip(*args)
  3  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:297 in run_pip
     self._env.run_pip(*args, **kwargs)
  2  /usr/local/lib/python3.7/site-packages/poetry/utils/env.py:916 in run_pip
     return self._run(cmd, **kwargs)
  1  /usr/local/lib/python3.7/site-packages/poetry/utils/env.py:1189 in _run
     return super(VirtualEnv, self)._run(cmd, **kwargs)
  EnvCommandError
  Command ['/builds/DataScience/alpaca/dashboard-voltage/.venv/bin/pip', 'install', '--no-deps', '/root/.cache/pypoetry/artifacts/e7/d7/77/4c5f7598a8dd9b001bc7aa898a3be217c5a49d068ea04bcdc12b15f886/pyparsing-2.4.7-py2.py3-none-any.whl'] errored with the following return code -7, and output: 
  
  at /usr/local/lib/python3.7/site-packages/poetry/utils/env.py:948 in _run
       944│                 output = subprocess.check_output(
       945│                     cmd, stderr=subprocess.STDOUT, **kwargs
       946│                 )
       947│         except CalledProcessError as e:
    →  948│             raise EnvCommandError(e, input=input_)
       949│ 
       950│         return decode(output)
       951│ 
       952│     def execute(self, bin, *args, **kwargs):
Read more comments on GitHub >

github_iconTop Results From Across the Web

Integrating Python Poetry with Docker - Stack Overflow
There are several things to keep in mind when using poetry together with docker . Installation. Official way to install poetry is via:...
Read more >
Announcing Poetry 1.2.0 | Blog
Due to bugs in older versions of pip, the parallel installer may sometimes experience race conditions. Modern pip versions should be highly ...
Read more >
Advanced Workflows with Parallel steps · Codefresh | Docs
Learn how to create complex workflows in Codefresh with step dependencies. ... If there are race conditions between your parallel steps, (e.g. multiple ......
Read more >
Can you share your experience with race conditions ... - Reddit
Can you share your experience with race conditions in production? I am trying to understand pitfalls of race conditions as a backend developer ......
Read more >
Alpine makes Python Docker builds slower, and images larger
I solved the problem by installing inotify into the container, ... and make debugging harder, race condition never happened to me anyway.
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