apt-get autocomplete package name is broken
Solution 1
As stated in the comments to the other answer, first make sure that bash-completion
is installed:
sudo apt-get install bash-completion
and apparently for @diapir, it helped to reinstall it:
sudo apt-get install --reinstall bash-completion
However, for me, the problem was not that bash-completion was not installed or broken, the problem was that I had accidently deleted my .bashrc
file. You can get a new one by copying it from /etc/skel
:
cp /etc/skel/.bashrc ~/
Solution 2
Type the following command:
sudo -H gedit /etc/bash.bashrc
Look for these lines:
# enable bash completion in interactive shells
# if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
# fi
Uncomment some lines, to make it look like this:
# enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Save, close terminal, then reopen it.
I have this issue after installing 13.04, and that's how I resolve it.
Solution 3
Note that output of this command:
apt-config dump | grep "Dir::Cache"
Should be something like this:
Dir::Cache "var/cache/apt";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
If value of Dir::Cache::pkgcache
is empty, apt will not be able to auto complete package names. Take a look at your /etc/apt/apt.conf.d/
files and search for this key to be sure that it's not set to empty string.
grep -r pkgcache /etc/apt/apt.conf.d/
Also take a look at this answer.
Solution 4
Download the latest stable release from http://bash-completion.alioth.debian.org/
./configure
make
sudo make install
insert
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
to ~/.bashrc
Related videos on Youtube
Comments
-
Cosmin Stefaniga almost 2 years
At some moment
apt-get install
autocomplete was broken
It was very useful to me to see packages name with Tab press
How to repair this autocomplete?
-
Oli over 12 yearsPlease edit your question to add more information. What does it do now when you press tab? Is there an error? Please include it.
-
koolhead17 over 12 yearsWhat package you were trying to find? Is it available via apt-cache search mypkg I am using Kubuntu on Oneiric i see it working well.
-
Cosmin Stefaniga over 12 yearsFor example I press tab after sudo apt-get install ruby, and terminal display me all packages with ruby: ruby-mysql, ryby-dev, etc.
-
Oli over 12 yearsYes, and what do you see instead when you press tab?
-
Cosmin Stefaniga over 12 yearsI see folders list, like cd +[TAB]
-
-
Caesium over 12 years
bash-completion
is in packages - is there any reason you did it manually? The package should do pretty much exactly this :) -
Cosmin Stefaniga over 12 years:) as always, sitting, reading manuals, configure, and then it turns out that this soft is exists in the repository
-
coda about 12 years
sudo apt-get install --reinstall bash-completion
did it for me. -
Anwar about 12 years@diapir, I have the same problem, but only reinstall does not working. I have to apply the lines in
bashrc
file. -
BHSPitMonkey over 11 yearsThanks, the bashrc tip solved the problem for me as well. The use of
sudo
on thechmod
command is unnecessary though, right? -
Kevin about 10 yearsthe file located in
/etc/
is0644/-rw-r--r--
with user:group =root:root
, and when copied to your user folder, will automatically go to user:user -
Jacob Abraham over 8 yearscp /etc/skel/.bashrc ~/ helped me solve this problem.
-
this.foo over 8 yearsthis was the only thing that worked for me. thank you.
-
Sergey about 8 yearsReinstall and copied /etc/skel/.bashrc helped me, thank you!
-
Rodrigo Lopez Guerra about 7 yearsWorked for me on Elementary OS LoKi
-
Alan Wang over 4 yearsLooks like this (and the link) is the correct answer if you have this issue inside a docker container.
-
Dave Ankin over 3 yearsthis still works tysm! just do
rm /etc/apt/apt.conf.d/docker-clean
-
polynomial_donut almost 3 yearsI just needed to reinstall bash-completion after upgrading from Debian 9 to Debian 10