From 4536218d33d315dbc63d866a9f1ebceedb256a47 Mon Sep 17 00:00:00 2001 From: Gerben Meijer Date: Sat, 9 Apr 2016 20:29:37 +0200 Subject: [PATCH 1/2] Move version sanity check to vagrant-libvirt.rb If this check is executed in plugin.rb, the message is not displayed on older versions of vagrant, which defeats the purpose of the test. --- lib/vagrant-libvirt.rb | 6 ++++++ lib/vagrant-libvirt/plugin.rb | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/vagrant-libvirt.rb b/lib/vagrant-libvirt.rb index 6118d71..0eb3619 100644 --- a/lib/vagrant-libvirt.rb +++ b/lib/vagrant-libvirt.rb @@ -13,5 +13,11 @@ module VagrantPlugins end end +# This is a sanity check to make sure no one is attempting to install +# this into an early Vagrant version. +if Vagrant::VERSION < '1.5.0' + raise 'The Vagrant Libvirt plugin is only compatible with Vagrant 1.5+' +end + # make sure base module class defined before loading plugin require 'vagrant-libvirt/plugin' diff --git a/lib/vagrant-libvirt/plugin.rb b/lib/vagrant-libvirt/plugin.rb index ae347c7..7316826 100644 --- a/lib/vagrant-libvirt/plugin.rb +++ b/lib/vagrant-libvirt/plugin.rb @@ -4,12 +4,6 @@ rescue LoadError raise 'The Vagrant Libvirt plugin must be run within Vagrant.' end -# This is a sanity check to make sure no one is attempting to install -# this into an early Vagrant version. -if Vagrant::VERSION < '1.5.0' - raise 'The Vagrant Libvirt plugin is only compatible with Vagrant 1.5+' -end - # compatibility fix to define constant not available vagrant <1.6 ::Vagrant::MachineState::NOT_CREATED_ID ||= :not_created From f8241645fcee4422f86a8761c8ddee0c2bdc4038 Mon Sep 17 00:00:00 2001 From: Gerben Meijer Date: Mon, 11 Apr 2016 16:02:42 +0200 Subject: [PATCH 2/2] Must load vagrant before checking version --- lib/vagrant-libvirt.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/vagrant-libvirt.rb b/lib/vagrant-libvirt.rb index 0eb3619..e1929e9 100644 --- a/lib/vagrant-libvirt.rb +++ b/lib/vagrant-libvirt.rb @@ -13,6 +13,12 @@ module VagrantPlugins end end +begin + require 'vagrant' +rescue LoadError + raise 'The Vagrant Libvirt plugin must be run within Vagrant.' +end + # This is a sanity check to make sure no one is attempting to install # this into an early Vagrant version. if Vagrant::VERSION < '1.5.0'