ewjoachim / poetry-to-pre-commit

A pre-commit hook for syncing version numbers between poetry.lock and .pre-commit-config.yaml
MIT License
0 stars 1 forks source link

Installation fails with `Unable to detect version control system` #7

Open souliane opened 3 months ago

souliane commented 3 months ago

This looks great! I tried it by it fails to install:

[INFO] Installing environment for https://github.com/ewjoachim/poetry-to-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/adrien/.cache/pre-commit/repox9p_hs86/py_env-python3.10/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /home/adrien/.cache/pre-commit/repox9p_hs86
      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
      ╰─> [26 lines of output]
          Traceback (most recent call last):
            File "/home/adrien/.cache/pre-commit/repox9p_hs86/py_env-python3.10/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/home/adrien/.cache/pre-commit/repox9p_hs86/py_env-python3.10/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
            File "/home/adrien/.cache/pre-commit/repox9p_hs86/py_env-python3.10/lib/python3.10/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-7c0o866h/overlay/lib/python3.10/site-packages/poetry/core/masonry/api.py", line 42, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/patch.py", line 26, in alt_poetry_create
              name = _get_and_apply_version(
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/__init__.py", line 608, in _get_and_apply_version
              version, instance = _get_version(config, name)
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/__init__.py", line 452, in _get_version
              version = _get_version_from_dunamai(vcs, pattern, config)
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/__init__.py", line 417, in _get_version_from_dunamai
              return Version.from_vcs(
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 1946, in from_vcs
              return cls._do_vcs_callback(
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 1985, in _do_vcs_callback
              return callback(**kwargs)
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 1906, in from_any_vcs
              vcs = _detect_vcs(None, path)
            File "/tmp/pip-build-env-7c0o866h/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 385, in _detect_vcs
              raise RuntimeError(" ".join(error_parts))
          RuntimeError: Unable to detect version control system. Checked: Git. Not installed: Mercurial, Darcs, Subversion, Bazaar, Fossil, Pijul.
          [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.
Check the log at /home/adrien/.cache/pre-commit/pre-commit.log
[1]    495558 exit 1     git commit -a

I don't know how to fix this :-p

souliane commented 3 months ago

Workaround:

poetry add git+https://github.com/ewjoachim/poetry-to-pre-commit

And use the local repo, e.g.:

  - repo: local
    hooks:
      - id: sync-repos
        name: sync-repos
        entry: sync-repos
        language: system
      - id: sync-hooks-additional-dependencies
        name: sync-hooks-additional-dependencies
        entry: sync-hooks-additional-dependencies
        args: [--bind, mypy=main]
        language: system
ewjoachim commented 3 months ago

Strange, it's as if pre-commit had pulled the repo but without .git. I wonder why, and why I didn't reproduce this in the repo I manage where I tested this, procrastinate

ewjoachim commented 3 months ago

Hm, I wasn't able to reproduce yet. I tried doing it in a docker so my setup is irrelevant, I tried with either rev: <tag> or rev: <commit>, and no reproduction. I tried seeing if the strict parameter would cause this error, but it causes a different one.

I tried older versions of pre-commit and it worked with 1.0.0 (and I can't imagine you'd have an older version than 1.0.0).

I can't find a setting in pre-commit that would impact how the repository is fetched (especially in a way that would end up with the repo not having .git).

I'll need you to share a bit more on your pre-commit config, your setup (computer vs CI) etc.

ewjoachim commented 3 months ago

I've tried something in #9 but it's just a hunch. Can you try and tell me if it solves it for you ?

souliane commented 3 months ago

I tried and it works with version 2.0.1, but I strangely was not able to reproduce with version 2.0.0 (also after pre-commit clean). Something was interfering, but I don't know what.

Sorry :-/ Since pre-commit.com is only for git, I think that #9 does not hurt.

ewjoachim commented 3 months ago

Well as long as it works :) Thanks for taking the time to test.

souliane commented 3 months ago

Just FYI, today the issue is here again, also with 2.0.1. We don't know if this is linked to this project or not, so I don't think that it is necessary to re-open.

ewjoachim commented 3 months ago

I'll keep it open in case someone else has the issue too for visibility