apt-file: Locate Missing Package Files

Ever had a source package fail to build due to a missing file? If so, apt-file, a tool that searches online repositories for a specific file, may be the answer.

Occasionally, when building a package from source, disaster strikes and the whole process grinds to a halt due to a missing file. Fortunately, this is increasingly uncommon due to the maturity of Linux package management and the ubiquity of Autoconf configuration scripts. However, some software projects don't use Autoconf, either because the maintainers prefer another solution such as CMake or because the program is too small to make setting up a configure script worthwhile.

Fortunately, on the rare occasions when this problem does crop up, there may be a solution in the form of apt-file: a member of the APT family of package management tools. This utility assembles an index of all of the files stored in the online repositories that your distribution is configured to use and allows you to search for individual files.

Case example: recently, I decided to check out KBackup, a KDE backup management utility that isn't currently in the Ubuntu repository. Following the instructions, I ran the CMake build tool, only to be disappointed when the build process stopped with a notice that it couldn't find a file called “FindKDE4Internal.cmake”.

To solve the problem, I installed apt-file via the command line:

sudo apt-get install apt-file

After installation, apt-file's internal index needs to be populated with the following command:

apt-file update

This process takes a minute or so to complete, depending on the speed of your Internet connection. Once the index was up to date, I searched for the missing file:

apt-file search FindKDE4Internal.cmake

and apt-file gave me a single line of output that told me everything I needed to know:

kdelibs5-dev: /usr/share/kde4/apps/cmake/modules/FindKDE4Internal.cmake

In other words, the file I needed was in the package “kdelibs5-dev”, which I installed from the command line:

sudo apt-get install kdelibs5-dev

After this, I was able to continue and complete the normal install procedure.

Note: if you do find an oversight in a source package that necessitates the use of apt-file in this way, even after a successful run of an Autoconf configure script, please consider telling the developers about it.


UK based freelance writer Michael Reed writes about technology, retro computing, geek culture and gender politics.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Very useful

Doug.Roberts's picture

Thanks for this. I've had to hunt down missing file packages before using the package manager & guesswork. This is much better.




John Knight's picture

Thanks man, this a problem I run into almost every month, cheers!

John Knight is the New Projects columnist for Linux Journal.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState