Skip to content

Instantly share code, notes, and snippets.

@petems
Created November 13, 2013 13:31
Show Gist options
  • Save petems/7449151 to your computer and use it in GitHub Desktop.
Save petems/7449151 to your computer and use it in GitHub Desktop.
Check Vagrant version
MIN_REQUIRED_VAGRANT_VERSION = '1.2.1'
if Vagrant::VERSION < MIN_REQUIRED_VAGRANT_VERSION
$stderr.puts "ERROR: We require Vagrant version >=#{min_required_vagrant_version}. Please upgrade. http://downloads.vagrantup.com/\n"
exit 1
end
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.hostname = 'foo'
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
end
@petems
Copy link
Author

petems commented Sep 18, 2020

Yeah, this is pretty old at this point (2013?), I think this pre-dates the Vagrant.version? method:

I later found that version comparisons in Ruby are fairly simple to do with the Gem library as well:

Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(MIN_REQUIRED_VAGRANT_VERSION)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment