Search code examples
flake8pre-commitpre-commit.com

Pre-commit suddenly fails to install Flake8


The pre-commit run suddenly fails without changes being made to the pre-commit configuration file. The log shows the following error message when attempting to initialise the environment for Flake8:

...
[INFO] Initializing environment for https://gitlab.com/pycqa/flake8.git.
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags')
return code: 128
expected return code: 0
stdout: (none)
stderr:
    fatal: could not read Username for 'https://gitlab.com': No such device or address
...

The pre-commit configuration file includes the following entry:

---
repos:
- repo: https://gitlab.com/pycqa/flake8.git
  rev: 3.9.2
  hooks:
  - id: flake8
    exclude: 'tests|env|docs'

Solution

  • The Flake8 project has moved to GitHub and requires updating the repository URL in the pre-commit configuration file:

    ---
    repos:
    - repo: https://github.com/pycqa/flake8.git
      rev: 3.9.2
      hooks:
      - id: flake8
        exclude: 'tests|env|docs'