{"record":{"id":"1a1e5b127e291c40","repo":"puppetlabs/puppet","slug":"could-not-autoload-name-detail","errorCode":null,"errorMessage":"Could not autoload %{name}: %{detail}","messagePattern":"Could not autoload %(.+?): %(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/autoload.rb","lineNumber":90,"sourceCode":"      end\n    end\n\n    # Load a single plugin by name.  We use 'load' here so we can reload a\n    # given plugin.\n    def load_file(name, env)\n      file = get_file(name.to_s, env)\n      return false unless file\n\n      begin\n        mark_loaded(name, file)\n        Kernel.load file\n        true\n      rescue SystemExit, NoMemoryError\n        raise\n      rescue Exception => detail\n        message = _(\"Could not autoload %{name}: %{detail}\") % { name: name, detail: detail }\n        Puppet.log_exception(detail, message)\n        raise Puppet::Error, message, detail.backtrace\n      end\n    end\n\n    def loadall(path, env)\n      # Load every instance of everything we can find.\n      files_to_load(path, env).each do |file|\n        name = file.chomp(\".rb\")\n        load_file(name, env) unless loaded?(name)\n      end\n    end\n\n    def reload_changed(env)\n      loaded.keys.each do |file|\n        if changed?(file, env)\n          load_file(file, env)\n        end\n      end\n    end","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/autoload.rb#L72-L108","documentation":"Puppet::Util::Autoload#load_file marks a name loaded and Kernel.load's the corresponding .rb file (an autoloaded provider, type, or face). SystemExit and NoMemoryError are re-raised untouched, but every other Exception is wrapped: Puppet.log_exception records it and a Puppet::Error 'Could not autoload %{name}: %{detail}' is raised with the original backtrace attached. The real cause is always in %{detail} — typically a SyntaxError, NameError, LoadError from a missing require, or an exception at class-evaluation time in the loaded file.","triggerScenarios":"A provider/type file under a module's lib/ or Puppet's own libdir containing a syntax error; the file requiring a gem that is not installed; the loaded file referencing a Puppet API constant removed in the running version; a custom provider failing at load time (e.g. Facter call at class scope). Trigger fires as soon as Puppet resolves the resource's provider during compilation.","commonSituations":"Module versions incompatible with the installed Puppet (major-version API removals); missing gem dependencies on the agent; partially-deployed or hand-edited module files; case errors in file names vs. autoloaded constants.","solutions":["Read the %{detail} portion of the message — it names the real exception and file:line","Syntax-check the file: ruby -c /path/to/the/mentioned/file.rb","Install missing runtime dependencies (gems) on the node, or fix the broken require","Pin/upgrade the module to a release matching your Puppet version (puppet module upgrade)"],"exampleFix":"# before (module file has a syntax error, e.g. lib/puppet/provider/foo/bar.rb)\nclass Puppet::Provider::Foo::Bar < Puppet::Provider\n  def self.instances   # missing 'end' below\nend\n\n# after\nclass Puppet::Provider::Foo::Bar < Puppet::Provider\n  def self.instances\n    []\n  end\nend","handlingStrategy":"try-catch","validationCode":"# Syntax-check module files before deploy\nrequire 'ruby_vm/instruction_sequence'\nDir['modules/*/lib/puppet/**/*.rb'].each do |f|\n  RubyVM::InstructionSequence.compile(File.read(f))\nrescue SyntaxError => e\n  abort \"#{f}: #{e.message}\"\nend","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::Util::Autoload.new(self, 'puppet/provider/foo').load(:myprovider, env)\nrescue Puppet::Error => e\n  # 'Could not autoload ...' — inspect e.cause/backtrace for the real exception\n  Puppet.err \"module load failed: #{e.message}\"\nend","preventionTips":["Run ruby -c on hand-edited provider/type files after changes","Pin module versions compatible with your Puppet major version (puppet module list --tree)","Install module gem dependencies on agents; deploy code atomically with r10k/code-manager, not rsync-in-progress copies","Read the detail segment of the message first — it carries the root exception and location"],"tags":["puppet","autoload","provider-loading","module-error"],"backgroundTag":"autoload-load-failure","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}