Mac上使用Vagrant启动bento/ubuntu-18.04虚拟机失败求助
linux-headers-4.15.0-12-generic No Installation Candidate on Old Ubuntu 18.04 Vagrant Box Hey, I’ve run into this exact issue before with outdated Ubuntu Vagrant boxes. The core problem here is that your bento/ubuntu-18.04 201803.24.0 box is way too old—its included kernel (4.15.0-12-generic) has had its corresponding headers package removed from Ubuntu’s active repositories. The GuestAdditions version mismatch is a secondary issue tied to this outdated box. Here’s how to fix it:
Step 1: Bypass GuestAdditions Auto-Update & Update the Kernel
First, we need to get the VM running without the failing GuestAdditions install:
- Edit your
Vagrantfileto disable automatic vbguest updates temporarily:
Vagrant.configure("2") do |config| # Keep your existing config here... config.vbguest.auto_update = false end
Run vagrant up—this should start the VM successfully now, since it skips the broken headers/GuestAdditions install.
- SSH into the VM with
vagrant ssh, then update the package lists and install the latest supported kernel for Ubuntu 18.04:
sudo apt update sudo apt install -y linux-generic
This will replace the old, unsupported kernel with a newer one that has available headers in the active repos.
- Reboot the VM to load the new kernel:
sudo reboot
Step 2: Re-enable GuestAdditions Auto-Update
Exit the VM, then edit your Vagrantfile again to remove the config.vbguest.auto_update = false line (or set it to true). Then run:
vagrant reload --provision
The vagrant-vbguest plugin will now automatically install the matching GuestAdditions version (5.2.12) for your host, and the new kernel’s headers will be available for installation—no more errors.
Alternative: Use a Newer bento/ubuntu-18.04 Box
If you don’t want to mess with updating the old box, just pull the latest version of the bento/ubuntu-18.04 box:
vagrant box update --box bento/ubuntu-18.04
Newer boxes include more recent kernels that still have supported headers in Ubuntu’s repos, so you won’t hit this issue in the first place.
内容的提问来源于stack exchange,提问作者Larry Martell

