You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ pipx install ansible-lint==6.16.2
$ ansible-lint --versionWARNING: PATH altered to include /home/ME/.local/pipx/venvs/ansible-lint/bin :: This is usually a sign of broken local setup, which can cause unexpected behaviors.ansible-lint 6.16.2 using ansible-core:2.15.0 ruamel-yaml:0.17.31 ruamel-yaml-clib:0.2.7A new release of ansible-lint is available: 6.16.2 → 6.17.0 Upgrade by running: pip install --upgrade ansible-lint
With RPM:
# dnf install ansible-lint
$ /usr/bin/ansible-lint --version
ansible-lint 6.16.2 using ansible-core:2.15.0 ruamel-yaml:0.17.24 ruamel-yaml-clib:0.2.7
Traceback (most recent call last):
File "/usr/bin/ansible-lint", line 8, in <module>
sys.exit(_run_cli_entrypoint())
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ansiblelint/__main__.py", line 310, in _run_cli_entrypoint
sys.exit(main(sys.argv))
^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ansiblelint/__main__.py", line 223, in main
msg = get_version_warning()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ansiblelint/config.py", line 302, in get_version_warning
pip = guess_install_method()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ansiblelint/config.py", line 229, in guess_install_method
for _ in uninstallation_paths(dist):
File "/usr/lib/python3.11/site-packages/pip/_internal/req/req_uninstall.py", line 45, in unique
for item in fn(*args, **kw):
File "/usr/lib/python3.11/site-packages/pip/_internal/req/req_uninstall.py", line 83, in uninstallation_paths
raise UninstallationError(msg)
pip._internal.exceptions.UninstallationError: Cannot uninstall ansible-lint 6.16.2, RECORD file not found. Hint: The package was installed by rpm.
ansible installation method: one of n/a
ansible-lint installation method: pipx/rpm
STEPS TO REPRODUCE
Install ansible-lint and run ansible-lint --version as shown in the steps above.
Desired Behavior
pipx:
ansible-lint --version should not suggest running pip install -U ansible-lint when it's installed in a pipx environment. It should not warn about WARNING: PATH altered to include /home/ME/.local/pipx/venvs/ansible-lint/bin :: This is usually a sign of broken local setup, which can cause unexpected behaviors. either.
I would argue that it shouldn't suggest running pip install -U in any case, as there's many environmental variations and this will be wrong in many cases, but pipx is a supported installation method and running pip install -U ansible-lint is definitely wrong when ansible-lint is installed with pipx.
RPM:
ansible-lint --version should not error out and should not suggest running pip install -U ansible-lint when it's installed via RPM.
ansible-lint is calling pip._internal.req.req_uninstall.uninstallation_paths() which does not work on RPM-installed Python packages. In dist-info directories, we purposely remove RECORD file (see https://peps.python.org/pep-0627/#optional-record-file) and set the contents of INSTALLER to rpm so users do not break their systems by trying to uninstall RPM-installed Python packages with pip uninstall.
There's a couple potential ways ansible-lint can handle this case:
Suppress pip._internal.exceptions.UninstallationError and move on like the code already does with AttributeError.
Check if importlib.metadata.distribution('ansible_lint').read_text('INSTALLER').strip() == "pip" and skip this code if it does not. This would need proper error handling for FileNotFoundErrors.
Actual Behavior
See ansible-lint --version output above.
The text was updated successfully, but these errors were encountered:
Summary
ansible-lint's version check breaks completely or gives incorrect instructions in certain cases.
Issue Type
OS / ENVIRONMENT
Fedora Rawhide container running ansible-lint 6.16.2
With pipx:
With RPM:
STEPS TO REPRODUCE
ansible-lint --version
as shown in the steps above.Desired Behavior
pipx:
ansible-lint --version
should not suggest runningpip install -U ansible-lint
when it's installed in a pipx environment. It should not warn aboutWARNING: PATH altered to include /home/ME/.local/pipx/venvs/ansible-lint/bin :: This is usually a sign of broken local setup, which can cause unexpected behaviors.
either.I would argue that it shouldn't suggest running
pip install -U
in any case, as there's many environmental variations and this will be wrong in many cases, but pipx is a supported installation method and runningpip install -U ansible-lint
is definitely wrong when ansible-lint is installed with pipx.RPM:
ansible-lint --version
should not error out and should not suggest runningpip install -U ansible-lint
when it's installed via RPM.ansible-lint is calling
pip._internal.req.req_uninstall.uninstallation_paths()
which does not work on RPM-installed Python packages. In dist-info directories, we purposely removeRECORD
file (see https://peps.python.org/pep-0627/#optional-record-file) and set the contents ofINSTALLER
torpm
so users do not break their systems by trying to uninstall RPM-installed Python packages withpip uninstall
.There's a couple potential ways ansible-lint can handle this case:
pip._internal.exceptions.UninstallationError
and move on like the code already does withAttributeError
.importlib.metadata.distribution('ansible_lint').read_text('INSTALLER').strip() == "pip"
and skip this code if it does not. This would need proper error handling forFileNotFoundError
s.Actual Behavior
See
ansible-lint --version
output above.The text was updated successfully, but these errors were encountered: