ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
787 stars 1.45k forks source link

pip_package_info: "no such option: --format" (--format added in pip 20.3b1) #8572

Open danowar2k opened 4 days ago

danowar2k commented 4 days ago

Summary

Listing pip packages, the task returns:

[WARNING]: Failed to retrieve packages with /some/path/to/some/pip: Unable to list
packages rc=2 :  Usage:      pip list [options]  no such option: --format

The reason is that pip only added the --format option in version 20.3b1 (see https://pip.pypa.io/en/stable/news/#b1-2020-10-31)

So either lower pip versions have to omit the --format option and extract package info otherwise OR you should add the minimum required pip version to the pip_package_info docs (see https://docs.ansible.com/ansible/latest/collections/community/general/pip_package_info_module.html#requirements)

Additional info: The used pip version was 8.1.1 so really old. pip_package_info should have been used to detect its version and then update that to a newer one.

Issue Type

Documentation Report

Component Name

pip_package_info

Ansible Version

(ansible-8.7.0) vagrant@ansible-cm:~/playbooks/playbook-mahara$ ansible --version
ansible [core 2.15.8]
  config file = /home/vagrant/playbooks/playbook-mahara/ansible.cfg
  configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vagrant/python-venvs/ansible-8.7.0/lib/python3.10/site-packages/ansible
  ansible collection location = /home/vagrant/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vagrant/python-venvs/ansible-8.7.0/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/home/vagrant/python-venvs/ansible-8.7.0/bin/python)
  jinja version = 3.0.3
  libyaml = True

Community.general Version

# /home/vagrant/python-venvs/ansible-8.7.0/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 7.5.2

Configuration

$ ansible-config dump --only-changed

OS / Environment

No response

Additional Information

If the docs are updated, users better understand when this module can be used.

Code of Conduct

ansibullbot commented 4 days ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 4 days ago

cc @bcoca @matburt @maxamillion click here for bot help

felixfontein commented 2 days ago

Using the --format parameter has been part of the module since it was initially created (https://github.com/ansible/ansible/pull/49079). I guess the requirements for this module should be updated to mention the minimum required pip version.

(If anyone wants to implement support for older pip versions as a new feature, feel free...)

danowar2k commented 2 days ago

I agree to just updating the docs (because I already did my task in another way ;-) ).