pre-commit fails to install isort 5.11.4 with error "RuntimeError: The Poetry configuration is invalid"


pre-commit suddenly started to fail installing the isort hook in our builds today with the following error

[INFO] Installing environment for
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/builds/.../.cache/pre-commit/repo0_h0f938/py_env-python3.8/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
      ERROR: Command errored out with exit status 1:
        File "/tmp/pip-build-env-_3j1398p/overlay/lib/python3.8/site-packages/poetry/core/masonry/", line 40, in prepare_metadata_for_build_wheel
          poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
        File "/tmp/pip-build-env-_3j1398p/overlay/lib/python3.8/site-packages/poetry/core/", line 57, in create_poetry
          raise RuntimeError("The Poetry configuration is invalid:n" + message)
      RuntimeError: The Poetry configuration is invalid:
        - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

It seems to be related with poetry configuration..

Asked By: bagerard



Upgrading the hook to the freshly released isort 5.12.0 seems to be fixing the issue.

Looking at the commit stack from isort repo, it sounds like recent version of Poetry had a breaking change incompatible with isort <= 5.11.4 (commit)

Answered By: bagerard

Additional note: For people who must use python3.7 (the support was dropped in isort 5.12.0), isort released the hotfix 5.11.5.

5.11.5 January 30 2023 [hotfix]

Fixed incompatiblity with latest poetry version

Related isort issue:

Answered By: zerocewl

Adding to this post because it took a few more things to get my system working…

Project fix

.pre-commit-config.yaml based on docs

- repo:
  rev: 5.12.0
  - id: isort
    args: ['--order-by-type', '--length-sort', "--profile", "black", "--filter-files"]
    name: isort (python)
  - id: isort
    name: isort (cython)
    types: [cython]
  - id: isort
    name: isort (pyi)
    types: [pyi]

pin specific poetry-core version (isort issue & hot fix)

requires = ["poetry-core>=1.3.2"]
build-backend = "poetry.core.masonry.api"

System fix

uninstall/reinstall poetry using official installer


curl -sSL | python3 - --uninstall
curl -sSL | POETRY_UNINSTALL=1 python3 -

check .zshrc and remove other instances of poetry via cat ~/.zshrc | grep poetry


curl -sSL | python3 -
echo "export PATH="/Users/$USER/.local/bin:$PATH"" >> "$HOME/.zshrc"
Answered By: will-wright-eng

Running pre-commit autoupdate was sufficient to fix it on my machine.

This will update isort version in .pre-commit-config.yaml to 5.12.0+, as well as all the other pre-commit utilities.

Answered By: Aleksei Petrenko

For me the solution was:

pre-commit autoupdate
Answered By: brenda