Bash auto-completion for apt-get & aptitude shows non-existent packages

Bug #600463 reported by Michał Gołębiowski-Owczarek
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
Invalid
Wishlist
Unassigned

Bug Description

Binary package hint: apt

When I type sth like that:
$ sudo apt-get install firefox[Tab]
I'm given a long list of non-existent (for a long time) packages, like firefox-2, firefox-3.0-dev etc. As they don't exist in Lucid (and never have) I shouldn't get the screen cluttered with them.

Could we just limit this list to packages actually existing in the current version?

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: apt 0.7.25.3ubuntu9
ProcVersionSignature: Ubuntu 2.6.32-23.37-generic 2.6.32.15+drm33.5
Uname: Linux 2.6.32-23-generic x86_64
NonfreeKernelModules: wl
Architecture: amd64
Date: Thu Jul 1 04:27:02 2010
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release amd64 (20091027)
SourcePackage: apt

Revision history for this message
Michał Gołębiowski-Owczarek (mgol) wrote :
Revision history for this message
Adam Collard (adam-collard) wrote :

 Thank you for taking the time to report this bug and helping to make Ubuntu better. The example packages you list still exist - they are dummy transitional packages - i'm therefore closing this bug. If you find other packages listed as completion targets which are genuinely non-existant, please re-open.

Changed in apt (Ubuntu):
status: New → Invalid
Revision history for this message
Michał Gołębiowski-Owczarek (mgol) wrote :

Right, I gave incorrect examples. Some valid ones are firefox-3.6, firefox-adblock-plus, python2.1 etc. In many cases (like this python one) all obsolete python versions have listings like:

$ apt-cache policy python2.5
python2.5:
  Installed: (none)
  Candidate: (none)
  Version table:

Changed in apt (Ubuntu):
status: Invalid → New
Revision history for this message
Torsten Spindler (tspindler) wrote :

Thanks for taking the time to report this issue! However, it seems to be explained in the man page of apt-cache. Some background information:
/etc/bash_completion.d/apt uses the following line to generate the packagenames:

                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \

From the manpage of apt-cache:

       pkgnames [ prefix ]
           This command prints the name of each package APT knows. The
           optional argument is a prefix match to filter the name list. The
           output is suitable for use in a shell tab complete function and the
           output is generated extremely quickly. This command is best used
           with the --generate option.

           Note that a package which APT knows of is not necessarily available
           to download, installable or installed, e.g. virtual packages are
           also listed in the generated list.

I tried to check if a package can be installed via a shellscript, but run time is limiting, for completeness here's the script I tested:
#!/bin/bash

pkgs=$(apt-cache pkgnames python2)

for pkg in $pkgs
do
  cand=$(apt-cache policy $pkg | grep Candidate)
  if [[ "$cand" =~ "Candidate: (none)" ]]
  then
    uninstallable="$uninstallable $pkg"
  else
    installable="$installable $pkg"
  fi
done

echo $installable

It seems the best solution would be to modify apt-cache and maybe add an option '--installable' to the pkgname argument to only show packages that have a candidate.

Changed in apt (Ubuntu):
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Michał Gołębiowski-Owczarek (mgol) wrote :

What I'm saying is that it's useless to display such packages in auto-completion so it should be changed.

I tried to add an "--installable" option to pkgnames but it didn't seem to help.

Revision history for this message
Torsten Spindler (tspindler) wrote :

I agree, it would be a good change to apt to add such an option. May I ask how far you've got with the --installable option idea?

Revision history for this message
Michał Gołębiowski-Owczarek (mgol) wrote :

I changed "pkgnames" in two places of file /etc/bash_completion.d/apt to "pkgnames --installable" and opened a new terminal.

Revision history for this message
Torsten Spindler (tspindler) wrote : Re: [Bug 600463] Re: Bash auto-completion for apt-get & aptitude shows non-existent packages

I see the misunderstanding - there is no such option, apt-cache needs to
be expanded by C/C++ coding to achieve that goal. I thought you might be
interested in implementing that.

Revision history for this message
Julian Andres Klode (juliank) wrote :

Not a bug. I don't think it's useful to complicate this thing just to get some packages filtered out in some circumstances. All those packages exist in the cache and you may need them, even if they are not real.

Changed in apt (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
Michał Gołębiowski-Owczarek (mgol) wrote :

Tell me just one use case when I might need packages that don't exist (and probably never will again).

Revision history for this message
David Kalnischkies (donkult) wrote :

$ LANG=C apt-get -s install mail-transport-agent
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mail-transport-agent is a virtual package provided by:
  xmail 1.27-1.1+b1
  ssmtp 2.64-4
  sendmail-bin 8.14.4-2
  qmail-run 2.0.2
  postfix 2.8.2-1+b1
  nullmailer 1:1.04-1.2
  msmtp-mta 1.4.23-1
  masqmail 0.2.27-1.2
  exim4-daemon-light 4.75-1
  exim4-daemon-heavy 4.75-1
  esmtp-run 1.2-5
  dma 0.0.2010.06.17-10
  courier-mta 0.65.3-2
  citadel-mta 7.84-3+b1
You should explicitly select one to install.

E: Package 'mail-transport-agent' has no installation candidate

mail-transport-agent is such a virtual package which never had and will never have a version available for installation, still it can be useful to see which packages provide it. It has other usecases as well - maybe more obscure, more developer centered -, but you asked for just one. :)

The command behind the tabcompletion is 'apt-cache pkgnames' and is designed to be as fast as possible. We would defeat the usefulness if we run full-fledged tests on these names as it would slow it down…

Revision history for this message
Julian Andres Klode (juliank) wrote :

This is actually a duplicate. And yes, pkgnames only shows non-virtual packages, DonKult, at least it did not give me mail-transport-agent.

Revision history for this message
Julian Andres Klode (juliank) wrote :

And the other bug is thus marked as Fix released.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.