I saw the silliest reason ever for the VBoxGuestAdditions being unable to find the correct kernel headers.
The story normally goes that you try to compile these things inside your virtual machine, the VBoxLinuxAdditions.run file will tell you to install kernel-devel, you do so and everything’s fine. Not today, though! Today the header files were undiscoverable.
I poked around for a while with no success and eventually just asked myself what the simplest possible problem could be. On a hunch I did:
ls /usr/src/kernels
3.10.0-862.14.4.el7.x86_64
uname -r
3.10.0-862.el7.x86_64
So the output of uname -r doesn’t contain one of the patchlevels that’s recorded in /usr/src/kernel.
This is because the following command installs the latest kernel-devel available in the rpm repos
sudo dnf install kernel-devel
But an older kernel is installed on the running system. I had to upgrade my running kernel
sudo dnf upgrade