With pre-commit 4.2.0 is all fine. With pre-commit 4.3.0 I see
Ansible-lint.............................................................Failed
- hook id: ansible-lint
- exit code: 1
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/root/.cache/pre-commit/repozusqqq7n/py_env-python3.12/lib/python3.12/site-packages/ansiblelint/__main__.py", line 50, in <module>
from ansiblelint import cli
File "/root/.cache/pre-commit/repozusqqq7n/py_env-python3.12/lib/python3.12/site-packages/ansiblelint/cli.py", line 13, in <module>
from ansiblelint.config import (
File "/root/.cache/pre-commit/repozusqqq7n/py_env-python3.12/lib/python3.12/site-packages/ansiblelint/config.py", line 118, in <module>
PROFILES = yaml_from_file(Path(__file__).parent / "data" / "profiles.yml")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.cache/pre-commit/repozusqqq7n/py_env-python3.12/lib/python3.12/site-packages/ansiblelint/loaders.py", line 40, in yaml_from_file
with open(str(filepath), encoding="utf-8") as content:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/pre-commit/repozusqqq7n/py_env-python3.12/lib/python3.12/site-packages/ansiblelint/data/profiles.yml'
Do you know how to fix this?
I tried to open an issue on pre-commit, but if I understand well they say that this is not supported.
Locally, I used uv to install Python 3.12 and the latest ansiblelint package in isolated environment to see if it includes a data/profiles.yml file and it does. Here’s what I got on my system:
That suggests that the problem with the file being “not found” is not in /that/ part of the path, but further up the tree in the part that pre-commit controls. Combined with your inside that it worked in pre-commit 4.2 but not 4.3 does suggest it’s a bug on their end.
Also, if you not running in a virtual machine or container, consider not using the root account for development, which brings security risks.