Is it possible to require certain Vagrant and VirtualBox versions in Vagrantfile?

StackOverflow https://stackoverflow.com/questions/23442277

  •  14-07-2023
  •  | 
  •  

Pregunta

I recently noticed that I managed to have a version of Vagrant and VirtualBox installed that did not work with my Vagrantfile. Upgrading to the latest Vagrant & VirtualBox fixed the problem.

Is it possible to ensure minimum Vagrant and VirtualBox versions are installed before allowing vagrant up to launch?

¿Fue útil?

Solución

For Vagrant itself, there is built-in support:

Vagrant.require_version ">= 1.3.5"

For Virtualbox, you can run some code at the top of your Vagrantfile like this:

if Gem::Version.new(`VBoxManage --version`.strip) < 
Gem::Version.new('5.1.6')
  abort "Please upgrade Virtualbox to 5.1.6 or later!"
end
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top