Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to install the pre-commit hook #544

Open
zaufi opened this issue Apr 4, 2024 · 3 comments
Open

Failed to install the pre-commit hook #544

zaufi opened this issue Apr 4, 2024 · 3 comments

Comments

@zaufi
Copy link

zaufi commented Apr 4, 2024

Install log

version information

pre-commit version: 3.6.1
git --version: git version 2.44.0
sys.version:
    3.12.2 (main, Mar 27 2024, 00:01:03) [GCC 13.2.0]
sys.executable: /usr/bin/python
os.name: posix
sys.platform: linux

error information

An unexpected error has occurred: CalledProcessError: command: ('/home/myuser/.cache/pre-commit/repo09xyg8bg/py_env-python3.12/bin/python', '-mpip', 'install', '.', './gitlint-core[trusted-deps]')
return code: 1
stdout:
    Looking in indexes: https://pypi.org/simple
    Processing /home/myuser/.cache/pre-commit/repo09xyg8bg
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    Processing ./gitlint-core
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    INFO: pip is looking at multiple versions of gitlint to determine which version is compatible with other requirements. This could take a while.
stderr:
    ERROR: Could not find a version that satisfies the requirement gitlint-core==0.1.dev1+gacc9d9d (from gitlint) (from versions: 0.17.0, 0.18.0, 0.19.0.dev73, 0.19.0.dev75, 0.19.0.dev76, 0.19.0.dev77, 0.19.0.dev78, 0.19.0.dev79, 0.19.0.dev80, 0.19.0.dev81, 0.19.0.dev82, 0.19.0rc1, 0.19.0rc2.dev1, 0.19.0rc2, 0.19.0rc3.dev1, 0.19.0, 0.19.1.dev1, 0.19.1.dev2, 0.19.1, 0.19.2.dev1, 0.19.2.dev2, 0.19.2.dev3, 0.19.2.dev4, 0.19.2.dev5, 0.20.0.dev2, 0.20.0.dev3, 0.20.0.dev6, 0.20.0.dev7, 0.20.0.dev8, 0.20.0.dev9, 0.20.0.dev10, 0.20.0.dev11, 0.20.0.dev12, 0.20.0.dev13, 0.20.0.dev14, 0.20.0.dev15, 0.20.0.dev16, 0.20.0.dev17, 0.20.0.dev18, 0.20.0.dev19, 0.20.0.dev20, 0.20.0.dev21, 0.20.0.dev22, 0.20.0.dev23, 0.20.0.dev24, 0.20.0.dev25, 0.20.0.dev27, 0.20.0.dev29, 0.20.0.dev30, 0.20.0.dev31, 0.20.0.dev32, 0.20.0.dev33, 0.20.0.dev34, 0.20.0.dev35, 0.20.0.dev36, 0.20.0.dev37, 0.20.0.dev38, 0.20.0.dev39, 0.20.0.dev40, 0.20.0.dev41, 0.20.0.dev42, 0.20.0.dev43, 0.20.0.dev44, 0.20.0.dev45, 0.20.0.dev48)
    ERROR: No matching distribution found for gitlint-core==0.1.dev1+gacc9d9d
Traceback (most recent call last):
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/main.py", line 389, in main
    return hook_impl(
           ^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/commands/hook_impl.py", line 271, in hook_impl
    return retv | run(config, store, ns)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/commands/run.py", line 442, in run
    install_hook_envs(to_install, store)
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/repository.py", line 238, in install_hook_envs
    _hook_install(hook)
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/repository.py", line 94, in _hook_install
    lang.install_environment(
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/languages/python.py", line 214, in install_environment
    lang_base.setup_cmd(prefix, install_cmd)
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/lang_base.py", line 86, in setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
  File "/home/myuser/.local/lib/python3.12/site-packages/pre_commit/util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/home/myuser/.cache/pre-commit/repo09xyg8bg/py_env-python3.12/bin/python', '-mpip', 'install', '.', './gitlint-core[trusted-deps]')
return code: 1
stdout:
    Looking in indexes: https://pypi.org/simple
    Processing /home/myuser/.cache/pre-commit/repo09xyg8bg
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    Processing ./gitlint-core
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'done'
    INFO: pip is looking at multiple versions of gitlint to determine which version is compatible with other requirements. This could take a while.
stderr:
    ERROR: Could not find a version that satisfies the requirement gitlint-core==0.1.dev1+gacc9d9d (from gitlint) (from versions: 0.17.0, 0.18.0, 0.19.0.dev73, 0.19.0.dev75, 0.19.0.dev76, 0.19.0.dev77, 0.19.0.dev78, 0.19.0.dev79, 0.19.0.dev80, 0.19.0.dev81, 0.19.0.dev82, 0.19.0rc1, 0.19.0rc2.dev1, 0.19.0rc2, 0.19.0rc3.dev1, 0.19.0, 0.19.1.dev1, 0.19.1.dev2, 0.19.1, 0.19.2.dev1, 0.19.2.dev2, 0.19.2.dev3, 0.19.2.dev4, 0.19.2.dev5, 0.20.0.dev2, 0.20.0.dev3, 0.20.0.dev6, 0.20.0.dev7, 0.20.0.dev8, 0.20.0.dev9, 0.20.0.dev10, 0.20.0.dev11, 0.20.0.dev12, 0.20.0.dev13, 0.20.0.dev14, 0.20.0.dev15, 0.20.0.dev16, 0.20.0.dev17, 0.20.0.dev18, 0.20.0.dev19, 0.20.0.dev20, 0.20.0.dev21, 0.20.0.dev22, 0.20.0.dev23, 0.20.0.dev24, 0.20.0.dev25, 0.20.0.dev27, 0.20.0.dev29, 0.20.0.dev30, 0.20.0.dev31, 0.20.0.dev32, 0.20.0.dev33, 0.20.0.dev34, 0.20.0.dev35, 0.20.0.dev36, 0.20.0.dev37, 0.20.0.dev38, 0.20.0.dev39, 0.20.0.dev40, 0.20.0.dev41, 0.20.0.dev42, 0.20.0.dev43, 0.20.0.dev44, 0.20.0.dev45, 0.20.0.dev48)
    ERROR: No matching distribution found for gitlint-core==0.1.dev1+gacc9d9d
@sigmavirus24
Copy link
Collaborator

There's far from enough details here to help you. Can you share your pre commit config file, or really any details of what you're using beyond version strings

@zaufi
Copy link
Author

zaufi commented Apr 4, 2024

The pre-commit could be trivial like this:

default_stages: [commit]

repos:
  - repo: https://github.com/jorisroovers/gitlint
    rev: v0.19.1
    hooks:
      - id: gitlint
        name: Commit message check
        language: python
        entry: gitlint --msg-filename
        stages: [commit-msg]

It was a host w/o any cached pre-commit repo yet... So, on git commit it started to clone remote repos w/ hooks.

$ python --version
Python 3.12.2
$ pre-commit --version
pre-commit 3.7.0

@zaufi
Copy link
Author

zaufi commented Apr 4, 2024

The solution that helped:

$ SETUPTOOLS_SCM_PRETEND_VERSION=0.19.1 git commit …

Needed only for the first time, when there is no cloned repo yet maintained by the pre-commit.

Definitely, it related to the dynamic version somewhere (I didn't dive into sources much)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants