diff --git a/lib/vagrant/plugin/v2/command.rb b/lib/vagrant/plugin/v2/command.rb index 3356d0320..52dd63733 100644 --- a/lib/vagrant/plugin/v2/command.rb +++ b/lib/vagrant/plugin/v2/command.rb @@ -1,6 +1,7 @@ require 'log4r' require "vagrant/util/safe_puts" +require "vagrant/util/silence_warnings" module Vagrant module Plugin @@ -130,12 +131,18 @@ module Vagrant @env.machine_index.release(entry) # Create an environment for this location and yield the - # machine in that environment. - env = Vagrant::Environment.new( - cwd: entry.vagrantfile_path, - home_path: @env.home_path, - ) - next env.machine(entry.name.to_sym, entry.provider.to_sym) + # machine in that environment. We silence warnings here because + # Vagrantfiles often have constants, so people would otherwise + # constantly (heh) get "already initialized constant" warnings. + machine = Vagrant::Util::SilenceWarnings.silence! do + env = Vagrant::Environment.new( + cwd: entry.vagrantfile_path, + home_path: @env.home_path, + ) + env.machine(entry.name.to_sym, entry.provider.to_sym) + end + + next machine end active_machines.each do |active_name, active_provider| diff --git a/lib/vagrant/util/silence_warnings.rb b/lib/vagrant/util/silence_warnings.rb new file mode 100644 index 000000000..c5b251df8 --- /dev/null +++ b/lib/vagrant/util/silence_warnings.rb @@ -0,0 +1,14 @@ +module Vagrant + module Util + module SilenceWarnings + # This silences any Ruby warnings. + def self.silence! + original = $VERBOSE + $VERBOSE = nil + return yield + ensure + $VERBOSE = original + end + end + end +end