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

pre-commit setup failure: KeyError: 'git-url' #807

Closed
ferronn-dev opened this issue Oct 29, 2023 · 2 comments · Fixed by #808
Closed

pre-commit setup failure: KeyError: 'git-url' #807

ferronn-dev opened this issue Oct 29, 2023 · 2 comments · Fixed by #808

Comments

@ferronn-dev
Copy link

With the following Dockerfile:

FROM mcr.microsoft.com/vscode/devcontainers/python
WORKDIR /repo
COPY .pre-commit-config.yaml .
RUN pip install pre-commit
RUN git init
RUN pre-commit

and .pre-commit-config.yaml:

repos:
- repo: https://github.com/JohnnyMorganz/StyLua
  rev: v0.18.2
  hooks:
  - id: stylua-github

Docker build fails. Here's the pre-commit log:

version information

pre-commit version: 3.5.0
git --version: git version 2.42.0
sys.version:
    3.12.0 (main, Oct  3 2023, 02:01:29) [GCC 12.2.0]
sys.executable: /usr/local/bin/python
os.name: posix
sys.platform: linux

error information

An unexpected error has occurred: CalledProcessError: command: ('/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /root/.cache/pre-commit/repon_d6qjtg
      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 'error'
stderr:
      error: subprocess-exited-with-error
      
      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [17 lines of output]
          Prepare meta /tmp/pip-modern-metadata-6b23go_n None
          Traceback (most recent call last):
            File "/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-qiw6zhf8/overlay/lib/python3.12/site-packages/pseudo_builder.py", line 104, in prepare_metadata_for_build_wheel
              metadata = read_metadata()
                         ^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-qiw6zhf8/overlay/lib/python3.12/site-packages/pseudo_builder.py", line 68, in read_metadata
              git_url = config.pop("git-url")
                        ^^^^^^^^^^^^^^^^^^^^^
          KeyError: 'git-url'
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed
    
    × Encountered error while generating package metadata.
    ╰─> See above for output.
    
    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/usr/local/lib/python3.12/site-packages/pre_commit/main.py", line 414, in main
    return run(args.config, store, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pre_commit/commands/run.py", line 442, in run
    install_hook_envs(to_install, store)
  File "/usr/local/lib/python3.12/site-packages/pre_commit/repository.py", line 248, in install_hook_envs
    _hook_install(hook)
  File "/usr/local/lib/python3.12/site-packages/pre_commit/repository.py", line 95, in _hook_install
    lang.install_environment(
  File "/usr/local/lib/python3.12/site-packages/pre_commit/languages/python.py", line 214, in install_environment
    lang_base.setup_cmd(prefix, install_cmd)
  File "/usr/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 "/usr/local/lib/python3.12/site-packages/pre_commit/util.py", line 110, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /root/.cache/pre-commit/repon_d6qjtg
      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 'error'
stderr:
      error: subprocess-exited-with-error
      
      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [17 lines of output]
          Prepare meta /tmp/pip-modern-metadata-6b23go_n None
          Traceback (most recent call last):
            File "/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/root/.cache/pre-commit/repon_d6qjtg/py_env-python3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-qiw6zhf8/overlay/lib/python3.12/site-packages/pseudo_builder.py", line 104, in prepare_metadata_for_build_wheel
              metadata = read_metadata()
                         ^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-qiw6zhf8/overlay/lib/python3.12/site-packages/pseudo_builder.py", line 68, in read_metadata
              git_url = config.pop("git-url")
                        ^^^^^^^^^^^^^^^^^^^^^
          KeyError: 'git-url'
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed
    
    × Encountered error while generating package metadata.
    ╰─> See above for output.
    
    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
@sblask
Copy link

sblask commented Oct 29, 2023

Looks like it's coming from the latest release of https://github.com/IamTheFij/release-gitter
Fixing to the previous release in pyproject.toml works:

requires = ["release-gitter[builder]==2.1.1"]

But there might be a proper fix. Unfortunately changing the pre-commit config like this doesn't help:

        additional_dependencies:
          - release-gitter==2.1.1

@rouge8
Copy link
Contributor

rouge8 commented Oct 31, 2023

I opened IamTheFij/release-gitter#3 to report this Nevermind, opened #808 with a fix

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

Successfully merging a pull request may close this issue.

3 participants