diff --git a/lib/vagrant-libvirt.rb b/lib/vagrant-libvirt.rb index 6118d71..e1929e9 100644 --- a/lib/vagrant-libvirt.rb +++ b/lib/vagrant-libvirt.rb @@ -13,5 +13,17 @@ 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' + 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