diff --git a/lib/vagrant/machine_index.rb b/lib/vagrant/machine_index.rb index f8ed442ba..6a30a4e60 100644 --- a/lib/vagrant/machine_index.rb +++ b/lib/vagrant/machine_index.rb @@ -3,6 +3,8 @@ require "pathname" require "securerandom" require "thread" +require "vagrant/util/silence_warnings" + module Vagrant # MachineIndex is able to manage the index of created Vagrant environments # in a central location. @@ -383,11 +385,13 @@ module Vagrant # # @return [Vagrant::Environment] def vagrant_env(home_path, **opts) - Environment.new({ - cwd: @vagrantfile_path, - home_path: home_path, - vagrantfile_name: @vagrantfile_name, - }.merge(opts)) + Vagrant::Util::SilenceWarnings.silence! do + Environment.new({ + cwd: @vagrantfile_path, + home_path: home_path, + vagrantfile_name: @vagrantfile_name, + }.merge(opts)) + end end # Converts to the structure used by the JSON diff --git a/lib/vagrant/plugin/v2/command.rb b/lib/vagrant/plugin/v2/command.rb index 423e6259c..8f957b901 100644 --- a/lib/vagrant/plugin/v2/command.rb +++ b/lib/vagrant/plugin/v2/command.rb @@ -1,7 +1,6 @@ require 'log4r' require "vagrant/util/safe_puts" -require "vagrant/util/silence_warnings" module Vagrant module Plugin @@ -134,13 +133,9 @@ module Vagrant # 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 = entry.vagrant_env( - @env.home_path, ui_class: @env.ui_class) - env.machine(entry.name.to_sym, entry.provider.to_sym) - end - - next machine + env = entry.vagrant_env( + @env.home_path, ui_class: @env.ui_class) + next env.machine(entry.name.to_sym, entry.provider.to_sym) end active_machines.each do |active_name, active_provider|