Skip to content

Instantly share code, notes, and snippets.

@AW-Britt
AW-Britt / restore_file_exists_method.rb
Created June 5, 2025 05:48
Workaround vagrant-vbguest plugin fail due to NoSuchMethod error on `File.exists?`
# Place this blurb at the top of your Vagrantfile to allow the unpatched
# version of the Vagrant vagrant-vbguest plugin to properly execute
# in newer Ruby environments where File.exists is no longer supported
#
# Extend the Ruby File class to restore the deprecated exists method
# calls File.exist instead
unless File.respond_to?(:exists?)
class << File
def exists?(path)
warn "File.exists? is deprecated; use File.exist? instead." unless ENV['SUPPRESS_FILE_EXISTS_WARNING']