TAB completion with 'dnf' problem

Issues related to applications and software problems and general support
Post Reply
AkosPrime
Posts: 30
Joined: 2006/01/07 17:51:29

TAB completion with 'dnf' problem

Post by AkosPrime » 2019/10/16 13:34:00

Is anyone else having a problem with TAB completion with 'dnf'? I've got the 'bash-completion' rpm installed. TAB completion works for commands like 'ls', 'cat', 'cp', but it doesn't work for 'dnf' - this is a little annoying when having to do a 'localinstall' option and the rpm file is 90 characters long. However, TAB completion DOES work if I use 'yum' instead. Is there some option that needs to be enabled in order for this to work for 'dnf'? Since 'dnf' is the new way of doing things, and since so many examples use it instead of 'yum', I'm trying to teach myself to use it instead. But not allowing tab completions makes that much more difficult, and has me falling back to utilizing the 'yum' command instead.

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: TAB completion with 'dnf' problem

Post by TrevorH » 2019/10/16 14:49:19

Since yum is a symlink to dnf-3, you should be quite safe to continue to use yum for now.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: TAB completion with 'dnf' problem

Post by hunter86_bg » 2019/10/16 16:01:28

According to Red Hat, they do not expect anyone to switch from yum...

AkosPrime
Posts: 30
Joined: 2006/01/07 17:51:29

Re: TAB completion with 'dnf' problem

Post by AkosPrime » 2019/10/22 14:28:40

TrevorH wrote:
2019/10/16 14:49:19
Since yum is a symlink to dnf-3, you should be quite safe to continue to use yum for now.
So 'yum' is symlinked to 'dnf' and it can do tab completion, but calling 'dnf' directly and you can't? Isn't that odd?

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: TAB completion with 'dnf' problem

Post by TrevorH » 2019/10/22 16:37:05

yum is the supported tool in RHEL.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mark0016
Posts: 1
Joined: 2019/10/31 08:34:06

Re: TAB completion with 'dnf' problem

Post by mark0016 » 2019/10/31 09:18:49

Since yum's autocompletion doesn't support the new dnf features like modules or groups I wanted to try weather the dnf command's autocompletion does and ran into the same issue. After some investigaton I've managed to make dnf's bash completion work in CentOS 8.0 but unfortunately the features I wanted are not much better in dnf's completion either.
The issue lies in that the bash completion script in /usr/share/bash-completion/completions/dnf uses a python helper to do it's completion. Yum is not effected since it's completion file is separate and doesn't rely on this helper. There are multiple issues that prevent this from working. If you realy want to use dnf then here's how to fix them.

1. The bash completion script wants to use the python executable at /usr/libexec/system-python or /usr/bin/python3 none of which exist by default.
Fix:
either install python3 to have the /usr/bin/python3 executable or create a symlink for system-python with

Code: Select all

ln -s /usr/bin/platform-python /usr/bin/system-python 
Alternatively you can edit the bash completion script to use /usr/libexec/platform-python instead

2. The pyhton helper it tries to use is missing from the dnf python module
Fix:

Copy the dnf/cli/completion_helper.py.in file from the official df github to the dnf module in python site-packages. Remove the .in extension and change the python executable at the beging of the file to the correct one.
Step by step:

Code: Select all

cd /usr/lib/python3.6/site-packages/dnf/cli
wget https://raw.githubusercontent.com/rpm-software-management/dnf/master/dnf/cli/completion_helper.py.in
Open the file with your favourite editor and replace the @PYTHON_EXECUTABLE@ with /usr/libexec/platform-python or just use sed

Code: Select all

sed -i -e 's/@PYTHON_EXECUTABLE@/\/usr\/libexec\/platform-python/g'
Last you just renam the file

Code: Select all

 mv completion_helper.py.in completion_helper.py 
With both these issues fixed dnf bash completion should work

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: TAB completion with 'dnf' problem

Post by TrevorH » 2019/10/31 15:40:06

I would suggest that you open a bug against it on bugzilla.redhat.com to report this and the fixes you've made. CentOS only repackages what is released for RHEL so to get things fixed you need to get them fixed in RHEL.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
carlwgeorge
Posts: 3
Joined: 2016/02/26 14:32:59

Re: TAB completion with 'dnf' problem

Post by carlwgeorge » 2020/03/25 15:40:06

This has been fixed upstream. That pull request references a closed bugzilla for a related issue, but the actual RHEL 8 bugzilla for this is here.

Post Reply