diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 3e8d41057..8996b3f80 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -31,9 +31,7 @@ module Vagrant def wsl? if !defined?(@_wsl) @_wsl = false - original_verbose = $VERBOSE - begin - $VERBOSE = nil + SilenceWarnings.silence! do # Use PATH values to check for `/mnt/c` path indicative of WSL if ENV.fetch("PATH", "").downcase.include?("/mnt/c") # Validate WSL via uname output @@ -42,8 +40,6 @@ module Vagrant @_wsl = true end end - ensure - $VERBOSE = original_verbose end end @_wsl diff --git a/lib/vagrant/util/which.rb b/lib/vagrant/util/which.rb index 12a07f327..0c8fd34d7 100644 --- a/lib/vagrant/util/which.rb +++ b/lib/vagrant/util/which.rb @@ -29,17 +29,13 @@ module Vagrant exts = ENV['PATHEXT'].split(';') end - current_verbose = $VERBOSE - $VERBOSE = nil - begin + SilenceWarnings.silence! do ENV['PATH'].encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = "#{path}#{File::SEPARATOR}#{cmd}#{ext}" return exe if File.executable? exe end end - ensure - $VERBOSE = current_verbose end return nil