Bug 2211862

Summary: python-argcomplete doesn't work when installed in completionsdir
Product: [Fedora] Fedora Reporter: Viktor Ashirov <vashirov>
Component: python-argcompleteAssignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 38CC: igor.raits, mfabik, mhroncok, msrb, python-packagers-sig, steve.traylen, tmz
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: python-argcomplete-2.0.0-8.fc39 python-argcomplete-2.0.0-8.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-06-08 02:02:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Viktor Ashirov 2023-06-02 10:55:22 UTC
In F38 installation of python-argcomplete script that is used for global completion activation was changed from compatdir (/etc/bash_completion.d) to completionsdir (/usr/share/bash-completion/completions):
https://src.fedoraproject.org/rpms/python-argcomplete/c/8c493c15eb35a2b798024771cde25ec73e818a72?branch=rawhide

Unfortunately, this breaks autocompletion for programs that rely on python-argcomplete being loaded. Completions from compatdir are loaded eagerly, unlike completionsdir. 

According to author of python-argcomplete:
> The pre-dynamic loading bash-completion directory is used because unfortunately, there is no way to hook a complete -D script into the bash-completion 2.0 infrastructure, and that is required for global completion activation. 

https://github.com/kislyuk/argcomplete/issues/426#issuecomment-1547135817

Please revert script installation to compatdir (/etc/bash_completion.d).



Reproducible: Always

Steps to Reproduce:
1. Use the following script:
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
import argcomplete, argparse

parser = argparse.ArgumentParser()
argcomplete.autocomplete(parser)
args = parser.parse_args()

2. chmod +x test.py
3. ./test.py<TAB><TAB>

Actual Results:  
Completion doesn't work

Expected Results:  
$ ./test.py -<TAB>
-h      --help

Version: python3-argcomplete-2.0.0-6.fc38.noarch

Comment 1 Miro Hrončok 2023-06-05 14:58:28 UTC
I've opened https://src.fedoraproject.org/rpms/python-argcomplete/pull-request/14 and https://src.fedoraproject.org/rpms/python-argcomplete/pull-request/15

I was unable to make see it working in a container, will try mock and if that fails, a real VM.

Comment 2 Miro Hrončok 2023-06-05 15:09:58 UTC
OK, it worked in a VM.

Comment 3 Todd Zullinger 2023-06-05 15:22:42 UTC
Thanks Miro.  I made essentially the same changes (I should read my bugzilla mail in full before doing anything :).

Comment 4 Fedora Update System 2023-06-05 20:56:38 UTC
FEDORA-2023-e1abb2006a has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-e1abb2006a

Comment 5 Fedora Update System 2023-06-05 22:10:12 UTC
FEDORA-2023-e1abb2006a has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 6 Fedora Update System 2023-06-06 09:25:58 UTC
FEDORA-2023-94df1a4de4 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-94df1a4de4

Comment 7 Fedora Update System 2023-06-07 01:38:37 UTC
FEDORA-2023-94df1a4de4 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-94df1a4de4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-94df1a4de4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2023-06-08 02:02:56 UTC
FEDORA-2023-94df1a4de4 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.