I was getting a crazy compilation error in my boost::thread library headers (which I didn't touch) so I deleted /usr/include/boost.
I purged libboost-all-dev and then did sudo apt-get install libboost-all-dev but the headers won't get back.
What should I do?
1 Answer
Uninstall libboost-all-dev again, then run sudo apt autoremove, then install libboost-all-dev again. That will usually work. These commands are one way to accomplish that:
sudo apt remove libboost-all-dev
sudo apt autoremove
sudo apt install libboost-all-devYou could use purge instead of remove and --purge autoremove instead of plain autoremove if you like, but in this case it sounds like the files you need restored aren't conffiles so that shouldn't matter.
libboost-all-dev is a metapackage. It doesn't provide any Boost libraries directly, but instead causes to them to be installed by declaring other packages that provide them as dependencies (run apt show libboost-all-dev for details). Uninstalling libboost-all-dev doesn't remove those packages, and since they were still installed when you installed libboost-all-dev again, they weren't reinstalled.
However, uninstalling libboost-all-dev does make those other packages eligible for automatic removal, so long as you didn't manually install them and nothing else that depends on them is installed. That's why performing the autoremove action when libboost-all-dev is uninstalled should fix the problem.
If it doesn't, you can investigate further by listing packages that are currently installed and are likely to be related to Boost:
apt list --installed '*boost*'You can then reinstall those with sudo apt --reinstall install ... or, better, uninstall them and then install libboost-all-dev again to get them back. I consider that better because then they're not marked as manually installed, and thus will be eligible for automatic removal in the future if you remove libboost-all-dev and nothing else depends on them.
Of course, when uninstalling packages, make sure to look at what apt--or apt-get, or whatever command you're using--says will be done. In particular, if you go to uninstall what appears to be a Booost-related package and the packages that will be removed along with it appear unrelated to Boost or are large in number, you should be reluctant to proceed. It is possible for non-Boost packages to depend on Boost-related packages.
Regarding your original problem with compile errors, you might consider posting a separate question about that once you've gotten the headers back.
More generally, if you want to try removing files that were installed by your package manager in order to troubleshoot a problem, it's best to use the package manager to uninstall them. If you do have to manually remove files, you should consider moving them somewhere else so you can easily restore them if necessary, rather than deleting them outright. Fortunately, removing files belonging to packages that aren't essential to the operation of the system--as you've done--can usually be undone pretty easily by reinstalling the correct packages.
1