poetry: Potential thread safety issue under certain environments: Incorrectly nested style tag found

In certain environments, specifically CI environments, this issue occurs randomly. It would seem that when using the new executor for installation the io being used is not thread safe and pastel fails attempting to pop the wrong stack.

  • Installing glob2 (0.6)

ValueError

Incorrectly nested style tag found.

  • Installing httpretty (0.9.7)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 13
  • Comments: 33 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I also have this problem when doing poetry (1.1.2) install in gitlab. The workaround is to disable the new installer: poetry config experimental.new-installer false

it seems to fail at a random point or sometimes not at all.

The installer is better in a few aspects outside of performance. Using installer.max-workers=1 would be what I recommend since the old one is due to be removed. And realistically, I do not think these edge cases can be handled at poetry level outside of a retry logic somewhere (which can lead to other issues) untill we drop pip as the wheel installer. That said, this particular issue, iirc has been fixed in newer versions of pip, so either doing poetry run python -m pip --upgrade pip or using 1.2 should resolve the issue. Feel free to reach out on discord if that helps.

@michalszelagsonos the issue is likely due to the parallel execution of multiple pip instances. In your case pygments being updated means the existing directory was deleted during the update, but before that it was listed as an existing path in another instance of pip (installation of traitlets) executing a call find_distributions which then tries to list files in this path.

You can workaround this by setting workers to 1. Also, try updating pip.

PS: I would recommend not disabling virtual environment creation, as sharing the system environment with poetry and other installations will only cause headaches. Besides, having a venv should reduce the probability of this collission.

Further, 1.2 should also improve this situation by not relying on system environment pip versions.