diff --git a/lib/vagrant/util/which.rb b/lib/vagrant/util/which.rb index 9a7ba5b23..12a07f327 100644 --- a/lib/vagrant/util/which.rb +++ b/lib/vagrant/util/which.rb @@ -29,11 +29,17 @@ module Vagrant exts = ENV['PATHEXT'].split(';') end - 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 + current_verbose = $VERBOSE + $VERBOSE = nil + begin + 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