A build fails with a missing header or a script asks for a binary that is not installed. I need the package name, not the file.
sudo apt install apt-file
sudo apt update
apt-file search bin/dig
apt-file find zlib.h
apt-file searches the Contents indexes of your repositories, so it also finds files of packages you have not installed. The default configuration makes a plain apt update fetch those indexes, and apt-file update is only a wrapper around apt update. search and find are the same command, and the pattern must match part of a file name. Add -x to use a regular expression, which can be slow. For files of installed packages, dpkg -S is faster.
Further reading: apt-file manual page