{"record":{"id":"6ed1652fddbc9f31","repo":"puppetlabs/puppet","slug":"no-file-s-found-for-import-of-pattern","errorCode":null,"errorMessage":"No file(s) found for import of '%{pattern}'","messagePattern":"No file\\(s\\) found for import of '%(.+?)'","errorType":"exception","errorClass":"TypeLoaderError","httpStatus":null,"severity":"error","filePath":"lib/puppet/parser/type_loader.rb","lineNumber":103,"sourceCode":"    Puppet.debug { \"importing '#{file}' in environment #{environment}\" }\n    parser = Puppet::Parser::ParserFactory.parser\n    parser.file = file\n    parser.parse\n  end\n\n  private\n\n  def import_from_modules(pattern)\n    modname, files = Puppet::Parser::Files.find_manifests_in_modules(pattern, environment)\n    if files.empty?\n      raise_no_files_found(pattern)\n    end\n\n    load_files(modname, files)\n  end\n\n  def raise_no_files_found(pattern)\n    raise TypeLoaderError, _(\"No file(s) found for import of '%{pattern}'\") % { pattern: pattern }\n  end\n\n  def load_files(modname, files)\n    @loaded ||= {}\n    loaded_asts = []\n    files.reject { |file| @loaded[file] }.each do |file|\n      # The squelch_parse_errors use case is for parsing for the purpose of searching\n      # for information and it should not abort.\n      # There is currently one user in indirector/resourcetype/parser\n      #\n      if Puppet.lookup(:squelch_parse_errors) { false }\n        begin\n          loaded_asts << parse_file(file)\n        rescue => e\n          # Resume from errors so that all parseable files may\n          # still be parsed. Mark this file as loaded so that\n          # it would not be parsed next time (handle it as if\n          # it was successfully parsed).","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parser/type_loader.rb#L85-L121","documentation":"Raised by Puppet::Parser::TypeLoader#import_from_modules via raise_no_files_found when Puppet::Parser::Files.find_manifests_in_modules returns an empty file list for the import pattern. The `import` statement expands glob patterns against module manifests; zero matches means the pattern (module name or file glob) resolves to nothing in the environment, which Puppet treats as an error rather than a silent no-op.","triggerScenarios":"`import 'users/*.pp'` when the users module has no .pp files matching; `import 'custom'` when module 'custom' is not in modulepath; `import 'foo/bar.pp'` where the file was moved/renamed; running under an environment whose modulepath differs from where the files live.","commonSituations":"Legacy Puppet 2.x/3.x code still using import after files were refactored into autoloaded classes; environment pinning (git branches) where a module exists in one branch but not the one being compiled; typos in glob patterns; upgrades to newer Puppet where import semantics were removed and previously-matching empty patterns now surface loudly.","solutions":["Verify the module exists in the compiling environment's modulepath and contains manifests matching the pattern.","Modernize: replace import with autoloaded layout — class foo::bar in foo/manifests/bar.pp is loaded automatically; delete the import statement.","Fix the glob: `import 'users/[a-z]*.pp'` vs an actual filename; check case sensitivity.","If the import is optional by design, guard it behind file existence checks in your wrapper tooling, since the DSL import itself cannot be made conditional."],"exampleFix":"# before\nimport 'users/*.pp'   # No file(s) found for import of 'users/*.pp'\n\n# after (autoloading - no import needed)\n# modules/users/manifests/init.pp -> class users\n# modules/users/manifests/admin.pp -> class users::admin\ninclude users::admin","handlingStrategy":"validation","validationCode":"# Ruby — probe the pattern before importing:\n_mod, files = Puppet::Parser::Files.find_manifests_in_modules(pattern, env)\ntype_loader.import(pattern) unless files.empty?\n# Shell — sanity check the glob:\n#   ls modules/<mod>/manifests/**/*.pp","typeGuard":null,"tryCatchPattern":"begin\n  type_loader.import(pattern)\nrescue Puppet::Parser::TypeLoaderError\n  # optional import — skip instead of failing compilation\nend","preventionTips":["Migrate away from import to the autoloader (class foo::bar in foo/manifests/bar.pp).","Keep glob patterns aligned with the actual file tree; add a CI check that every import pattern matches >=1 file.","Ensure the referenced module exists in every environment branch that compiles it."],"tags":["puppet","import","module-path","manifests","legacy"],"backgroundTag":"manifest-import-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}