Fixing vagrant plugin error
Fixing vagrant plugins if they fail to initialize after an upgrade.
This is a quick guide on how to fix issues with vagrant plugins that can happen when upgrading from an older vagrant version on Mac.
Most of my work today is either in Ping One Advanced Identity Cloud or in a kubernetes based ForgeOps deployment. But every now and then, all I need is a VM running some software, for example, a standalone PingAM. I find the easiest way to manage VMs is by using vagrant. It's been a while since I last used it, so I ran an update to the latest version and tried to initiate a box.
The issue
vagrant init bento/rockylinux-9.5
But instead of initialising a Vagrant file, I got an error message:
Vagrant failed to initialize at a very early stage:
The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:
vagrant plugin repair
If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:
vagrant plugin expunge --reinstall
Or you may want to try updating the installed plugins to their latest
versions:
vagrant plugin update
Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-disksize (= 0.1.3)'
The error message gives some good suggestions on resolving the issue, so I tried following them one by one up to:
Vagrant plugin expunge --reinstall
This would still throw an error, albeit a different one:
Vagrant failed to properly resolve required dependencies. These
errors can commonly be caused by misconfigured plugin installations
or transient network issues. The reported error is:
Unable to resolve dependency: user requested 'vagrant-vbguest (= 0.30.0)'
Why does this error happen
When Vagrant upgrades, its internal Ruby‑gem ecosystem can end up with mismatched plugin versions. The expunge
command clears out old gems; vbguest
or disksize
then must be reinstalled to resolve dependencies.
The fix
So to resolve this, I had to run the plugin expunge --reinstall
command, then install the failing vagrant-vbguest
plugin and then again run the plugin expunge --reinstall
command
- Backup existing plugins (optional):
cp -r ~/.vagrant.d ~/.vagrant.d.backup
- Expunge and reinstall everything:bashCopyEdit
vagrant plugin expunge --reinstall
- Install any failing plugin manually:bashCopyEdit
vagrant plugin install vagrant-vbguest
- Re‑verify:
vagrant plugin list
vagrant init bento/rockylinux-9.5
The vagrant box should now initialise just fine.
Hope this helps if someone comes across the same error.