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

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

  •  14-07-2023
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top