class Zeitwerk::GemLoader
def warn_on_extra_files
def warn_on_extra_files expected_namespace_dir = @root_file.delete_suffix(".rb") ls(@root_dir) do |basename, abspath| next if abspath == @root_file next if abspath == expected_namespace_dir basename_without_ext = basename.delete_suffix(".rb") cname = inflector.camelize(basename_without_ext, abspath).to_sym ftype = dir?(abspath) ? "directory" : "file" warn(<<~EOS) WARNING: Zeitwerk defines the constant #{cname} after the #{ftype} #{abspath} To prevent that, please configure the loader to ignore it: loader.ignore("\#{__dir__}/#{basename}") Otherwise, there is a flag to silence this warning: Zeitwerk::Loader.for_gem(warn_on_extra_files: false) EOS end end